• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

a guest Apr 21st, 2019 100 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. diff :: [(a,b)] -> [c]
2. diff [] = []
3. diff ((a,b):xs) = (a-b):(diff xs)
4.
5. GHCI ERROR MESSAGES:
6.
8.     • Couldn't match type ‘a’ with ‘c’
9.       ‘a’ is a rigid type variable bound by
10.         the type signature for:
11.           diff :: forall a b c. [(a, b)] -> [c]
13.       ‘c’ is a rigid type variable bound by
14.         the type signature for:
15.           diff :: forall a b c. [(a, b)] -> [c]
17.       Expected type: [c]
18.         Actual type: [a]
19.     • In the expression: (a - b) : (diff xs)
20.       In an equation for ‘diff’: diff ((a, b) : xs) = (a - b) : (diff xs)
21.     • Relevant bindings include
22.         xs :: [(a, b)] (bound at addprime.hs:3:13)
23.         a :: a (bound at addprime.hs:3:8)
24.         diff :: [(a, b)] -> [c] (bound at addprime.hs:2:1)
25.   |
26. 3 | diff ((a,b):xs) = (a-b):(diff xs)
27.   |                   ^^^^^^^^^^^^^^^
28.
30.     • Couldn't match expected type ‘a’ with actual type ‘b’
31.       ‘b’ is a rigid type variable bound by
32.         the type signature for:
33.           diff :: forall a b c. [(a, b)] -> [c]
35.       ‘a’ is a rigid type variable bound by
36.         the type signature for:
37.           diff :: forall a b c. [(a, b)] -> [c]
39.     • In the second argument of ‘(-)’, namely ‘b’
40.       In the first argument of ‘(:)’, namely ‘(a - b)’
41.       In the expression: (a - b) : (diff xs)
42.     • Relevant bindings include
43.         xs :: [(a, b)] (bound at addprime.hs:3:13)
44.         b :: b (bound at addprime.hs:3:10)
45.         a :: a (bound at addprime.hs:3:8)
46.         diff :: [(a, b)] -> [c] (bound at addprime.hs:2:1)
47.   |
48. 3 | diff ((a,b):xs) = (a-b):(diff xs)
49.   |                      ^