
15 Dec
2010
15 Dec
'10
10:21 p.m.
On Wed, Dec 15, 2010 at 10:37:02PM +0100, Tim Baumgartner wrote:
Hello Haskellers,
I defined
newtype Banana = Banana Something
When I work with it, I sometimes use a function
mapBanana f (Banana b) = Banana (f b)
which is of course discarded by the compiler. Is this usual practice or are there any better solutions?
This is the usual practice. Think of it as part of the (small) price we pay to have nice type inference. You may also be interested in reading about Conal Elliott's notion of "semantic editor combinators" [1], of which your 'mapBanana' is an example. -Brent [1] http://conal.net/blog/posts/semantic-editor-combinators/