Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. --mapMyList f Empty = Empty
  2. --mapMyList f (x :-: xs) = f x :-: mapMyList f xs
  3.  
  4.  
  5.  
  6. tailRecursionEngine termCond termFn wayAheadFn =
  7. tailRecursiveFn
  8. where tailRecursiveFn y
  9. | termCond y = termFn y
  10. | otherwise = (tailRecursiveFn (wayAheadFn y))
  11.  
  12. -- :: (t1 -> Bool) -> (t1 -> t) -> (t1 -> t1) -> t1 -> t
  13.  
  14. data List a = Empty | a :-: List a deriving (Read, Eq, Ord)
  15.  
  16. mapMyList1 :: (t -> a) -> List t -> List a
  17.  
  18. myNull Empty = True ; myNull (x :-: xs) = False
  19.  
  20. mapMyList1 f xs =
  21. tailRecursionEngine
  22. (myNull ) --- termination Condition
  23. (\_ -> f(head :-: xs))
  24. (:-:) --- Error message is in this line
  25.  
  26.  
  27.  
  28. Error Message
  29.  
  30.  
  31. Couldn't match expected type `List t'
  32. against inferred type `List (List t) -> List (List t)'
  33. In the third argument of `tailRecursionEngine', namely `(:-:)'
  34. In the expression:
  35. tailRecursionEngine (myNull) (\ _ -> f (head :-: xs)) (:-:)
  36. In the definition of `mapMyList1':
  37. mapMyList1 f xs
  38. = tailRecursionEngine (myNull) (\ _ -> f (head :-: xs)) (:-:)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement