Skip to content

Instantly share code, notes, and snippets.

@jccarbonfive
Created September 9, 2012 03:15
Show Gist options
  • Select an option

  • Save jccarbonfive/3682372 to your computer and use it in GitHub Desktop.

Select an option

Save jccarbonfive/3682372 to your computer and use it in GitHub Desktop.
Prelude> let sum x y = x + y
Prelude> :type sum
sum :: Num a => a -> a -> a
Prelude> let f = sum 3
Prelude> :type f
f :: Integer -> Integer
Prelude> f 4
7
Prelude> let double = (* 2)
Prelude> :type double
double :: Integer -> Integer
Prelude> :type (2 ^)
(2 ^) :: (Integral b, Num a) => b -> a
Prelude> :type map (+ 1)
map (+ 1) :: Num b => [b] -> [b]
Prelude> :type map (\x -> x + 1)
map (\x -> x + 1) :: Num b => [b] -> [b]
Prelude> let s = foldl (+) 0
Prelude> :type s
s :: [Integer] -> Integer
Prelude> let prod xs = foldl (*) 1 xs
Prelude> prod [1, 2, 3, 4]
24
Prelude> let prod = foldl (*) 1
Prelude> prod [1, 2, 3, 4]
24
Prelude> :type "hello"
"hello" :: [Char]
Prelude> :kind [Char]
[Char] :: *
Prelude> :kind Either
Either :: * -> * -> *
Prelude> :kind Either String
Either String :: * -> *
Prelude> :kind Either String Int
Either String Int :: *
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment