[Haskell-cafe] How to "Show" an Operation?

Martin Drautzburg Martin.Drautzburg at web.de
Wed Jun 9 14:33:06 EDT 2010

On Monday, 7. June 2010 23:28:08 Evan Laforge wrote:

> I just meant you could add instances:
> instance Functor (Named a) where fmap f named = named { val_of = f
> (val_of named) }
> instance Applicative (Named a) where ... likewise, but maybe not a
> great fit unless you have a "no name" for 'pure'

So far so good. However my "Named" things are all functions and I don't see I 
ever want to map over any of them. But what I'd like to do is use them like 
ordinary functions as in:

f::Named (Int->Int)
f x

Is there a way to do this, other than writing

apply::Named Int ->Int
apply n x = (val_of n) x


More information about the Haskell-Cafe mailing list