[Haskell-beginners] type question

Daniel Fischer daniel.is.fischer at googlemail.com
Wed Jun 29 17:23:29 CEST 2011


On Wednesday 29 June 2011, 16:55:50, Roelof Wobben wrote:
> Hello,
> 
> I'm now following the book Programming in Haskel by Hutton.
> IM now reading the chapter about types.
> 
> But I don't understand this :
> 
> False :: Bool
> True :: Bool
> ¬  :: Bool  ---> Bool
> 
> So False  and True has the type Bool.
> That's clear.
> 
> I find out that ¬ makes the opposite of True and False.
> But why is it also the type Bool --> Bool

It's a function from Bool to Bool, that type is denoted by

Bool -> Bool

in Haskell (generally, "a -> b" is the type of functions taking an argument 
of type "a" and returning a value of type "b"; it's particularly 
interesting if "b" is itself a type of functions, e.g. "b = c -> d", then 
the function has type "a -> (c -> d)" or "a -> c -> d" [in that position, 
the parentheses are optional, since the function arrow associates to the 
right], and it can also be regarded as the type of functions taking two 
arguments, one of type "a", one of type "c" and returning a value of type 
"d"; now, "d" might again be a function type, ...).

Note that normally, it's written "not", and not with a fancy unicode 
symbol.

> 
> Roelof




More information about the Beginners mailing list