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.  
  7. addprime.hs:3:19: error:
  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]
  12.         at addprime.hs:1:1-22
  13.       ‘c’ is a rigid type variable bound by
  14.         the type signature for:
  15.           diff :: forall a b c. [(a, b)] -> [c]
  16.         at addprime.hs:1:1-22
  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.  
  29. addprime.hs:3:22: error:
  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]
  34.         at addprime.hs:1:1-22
  35.       ‘a’ is a rigid type variable bound by
  36.         the type signature for:
  37.           diff :: forall a b c. [(a, b)] -> [c]
  38.         at addprime.hs:1:1-22
  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.   |                      ^
  50. Failed, no modules loaded.
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top