[Haskell-cafe] Can I determin the function name passed in?

Ketil Malde ketil+haskell at ii.uib.no
Thu Oct 7 06:38:25 EDT 2004


Keith Wansbrough <Keith.Wansbrough at cl.cam.ac.uk> writes:

> Instead, you should pass around data items that
> contain both the function and its name - either just pairs, [...]
> or proper data types

...or both, using records:

   data NamedFunc a b = NamedFunc { nameOf :: String, apply :: (a->b) }

   f = NamedFunc "successor" (\x -> x+1)
   apply f 4
   => 5
   nameOf f
   => "successor"

-kzm
-- 
If I haven't seen further, it is by standing in the footprints of giants


More information about the Haskell-Cafe mailing list