[Haskell-cafe] On to applicative
Vo Minh Thu
noteed at gmail.com
Thu Aug 26 02:02:56 EDT 2010
2010/8/26 michael rice <nowgate at yahoo.com>
> From: http://en.wikibooks.org/wiki/Haskell/Applicative_Functors
> import Control.Applicative
> f :: (a -> b -> c)
> fmap :: Functor f => (d -> e) -> f d -> f e
> fmap f :: Functor f => f a -> f (b -> c) -- Identify d with a, and e with (b -> c)
> sumsqr :: Int -> Int -> Int -- my f
> sumsqr i j = i*i+j*j
> I'm trying to understand how the above works but...
> [michael at localhost ~]$ ghci
> GHCi, version 6.12.1: http://www.haskell.org/ghc/ :? for help
> Loading package ghc-prim ... linking ... done.
> Loading package integer-gmp ... linking ... done.
> Loading package base ... linking ... done.
> Loading package ffi-1.0 ... linking ... done.
> Prelude> :l bozo.hs
> [1 of 1] Compiling Main ( bozo.hs, interpreted )
> bozo.hs:5:0: Invalid type signature
> Failed, modules loaded: none.
The fifth line has the form
x y :: ...
x :: ...
This is not a legal type signature.
Furthermore, you can't give fmap two signatures in the same source file.
The reason this is given on the page you linked is for demonstration
purpose (well, I guess, I haven't read it).
More information about the Haskell-Cafe