[Haskell-beginners] (->) reader/environment

Martin Vlk martin at vlkk.cz
Thu Jul 23 08:07:04 UTC 2015


Hi, this one is a bit of a mystery to me.

I am working on solutions to cis194/NICTA Haskell exercises and among
others I am asked to work with (->).

I understand it refers to the reader/environment design patterns, but I
am stumped as for what exactly it is. It doesn't seem to be an ordinary
type, I know it is used as type constructor in type declarations, so
that suggests it's a function, but somehow special. Looking in Hoogle it
seems to be Haskell keyword - e.g. not an ordinary function.

So what is it - type constructor, a keyword, how is it related to the
reader/environment pattern?

>From GHCI's :info (->) I get:
data (->) a b 	-- Defined in ‘ghc-prim-0.4.0.0:GHC.Prim’
instance P.Monad ((->) r) -- Defined in ‘GHC.Base’
instance P.Functor ((->) r) -- Defined in ‘GHC.Base’
instance P.Applicative ((->) a) -- Defined in ‘GHC.Base’
instance P.Monoid b => P.Monoid (a -> b) -- Defined in ‘GHC.Base’

Cheers
Martin


More information about the Beginners mailing list