Friday 29 April 2016

Haskell: Operators are functions

Haskell implements operators as functions. Just like how you get type signature of a variable, function, you can also get the type signature of an operator by using :t command.
Prelude> :t (+)
(+) :: Num a => a -> a -> a
Prelude> 
Prelude> :t (*)
(*) :: Num a => a -> a -> a
Prelude> 
Prelude> :t (==)
(==) :: Eq a => a -> a -> Bool
Prelude> 
Prelude> :t (&&)
(&&) :: Bool -> Bool -> Bool


Previous                                                 Next                                                 Home

No comments:

Post a Comment