I'm learning Haskell via Learn You a Haskell and I'm pretty sure he went over this at some point but I can't figure out where. Say I want to have a function return a pair, list of pairs, or general tuple. How is the type signature for this written? For example, for some given even number I want to return the list of unique pairs of primes that add up to it. I have a function isPrime
that tells whether or not an Int
is a prime.
pairs :: Int -> [(Int a, Int b)]
pairs n
| n < 4 = []
| odd n = []
| otherwise = [(a, b) | a < b, isPrime a, isPrime b, a+b == 1]
When I try to compile this, I get the error saying "Int has too few arguments." So I tried the following syntax instead:
pairs :: Int -> [((Int a), (Int b))]
But I got the same error. So in general how does typesetting functions involving pairs work?