Re:The Nature of Lisp (2006)
by eru on Wednesday May 05, 2010 @05:49PM
(#1322711)
In the example
my_fun :: (TypeClass1 a, Typeclass2 b) => a -> b
the stuff preceeding the => declares what typeclasses the types you mention later should fall into.
A good example is the module Data.Map; this module deals with finite mappings of keys to values. Since those Maps are based on balanced trees, the keys have to be orderable/comparable. So for inserting a key into a map (http://hackage.haskell.org/packages/archive/containers/0.2.0...) we get the following type
A good example is the module Data.Map; this module deals with finite mappings of keys to values. Since those Maps are based on balanced trees, the keys have to be orderable/comparable. So for inserting a key into a map (http://hackage.haskell.org/packages/archive/containers/0.2.0...) we get the following type
This just says that the type of keys has to be an instance of the class Ord (http://haskell.org/ghc/docs/6.12.1/html/libraries/base-4.2.0...). I.e. there has to be an instance declaration with the function Does that help?By the way, if you want to find documentation about a function and you know its name or type, you can use Hoogle (http://www.haskell.org/hoogle/).