| I have a small question about defining functions over types declared
| with "newtype".  Consider the following:
| 
|    newtype MyList a = MyList [a]
| 
|    myMap1 :: (a -> b) -> MyList a -> MyList b

I would say

        myMap f (MyList xs) = MyList (map f xs)

| Perhaps there is no elegant solution to this, but as long as I can
| rely on the above code generating no more work than necessary, I am
| content.

Yes it's a bit cumbersome at times, but it is clear what it means,
including what happens with overloading.  It is often useful to
define unMyList :: MyList a -> [a], as you do.

You should get no code for the extra constructors, but I am not confident
that GHC always does a good job.

Simon



Reply via email to