Haskell type signature with multiple class constraints
They’re usually called class constraints, as Eq and Num are called type-classes. How about this? f :: (Eq a, Num b) => a -> b The parentheses are significant.
They’re usually called class constraints, as Eq and Num are called type-classes. How about this? f :: (Eq a, Num b) => a -> b The parentheses are significant.
I’ll start with map. The map function applies an operation to every element in a list. If I had add3 :: Int -> Int add3 x = x + 3 Then I could apply this to a whole list of Ints using map: > map add3 [1, 2, 3, 4] [4, 5, 6, 7] So … Read more