Haskell type signature with multiple type somethings (predicates?, for example Eq a =>)
Posted
by
Andrew
on Stack Overflow
See other posts from Stack Overflow
or by Andrew
Published on 2012-06-19T03:03:33Z
Indexed on
2012/06/19
3:16 UTC
Read the original article
Hit count: 153
I'm not sure if type predicates is the right term, in fact I've never learned the word for this, so an edit to correct would be helpful - I'm referring to when you give the tipe of function f :: a -> b
and you want to say a
is a Eq and you say f :: Eq a => a -> b
, the name for Eq a =>
- this is the thing i called a type predicate.
My question, though, is how to have multiple of these, so if A is an Eq and B is a Num, I could say either f :: Eq a => a -> b
or f :: Num b => a -> b
.
So, how can I have Eq a =>
and Num b =>
at the same time?
f :: Eq a => Num b => a -> b
,
f :: Eq a -> Num b => a -> b
, and
f :: Eq a, Num b => a -> b
all didn't do what I wanted.
© Stack Overflow or respective owner