Advertisement
Guest User

Untitled

a guest
Dec 16th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. {-# LANGUAGE DataKinds            #-}
  2. {-# LANGUAGE KindSignatures       #-}
  3. {-# LANGUAGE PolyKinds            #-}
  4. {-# LANGUAGE TypeFamilies         #-}
  5. {-# LANGUAGE TypeInType           #-}
  6. {-# LANGUAGE TypeOperators        #-}
  7. {-# LANGUAGE UndecidableInstances #-}
  8.  
  9. import Data.Kind (Constraint, Type)
  10.  
  11. type Exp a = a -> Type
  12.  
  13. type family Eval (e :: Exp a) :: a
  14.  
  15. data MapList :: (a -> Exp b) -> [a] -> Exp b
  16.  
  17. type instance Eval (MapList f '[]) = '[]
  18. type instance Eval (MapList f (a ': as)) =
  19.    Eval (f a) ': Eval (MapList f as)
  20.  
  21. {- error:
  22. [1 of 1] Compiling Main             ( tys3.hs, interpreted )
  23.  
  24. tys3.hs:19:5: error:
  25.     • Occurs check: cannot construct the infinite kind: a0 ~ [a0]
  26.     • In the type ‘Eval (f a) : Eval (MapList f as)’
  27.       In the type instance declaration for ‘Eval’
  28.    |
  29. 19 |     Eval (f a) ': Eval (MapList f as)
  30.    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  31.  
  32. tys3.hs:19:19: error:
  33.     • Occurs check: cannot construct the infinite kind: a0 ~ [a0]
  34.     • In the second argument of ‘(:)’, namely ‘Eval (MapList f as)’
  35.       In the type ‘Eval (f a) : Eval (MapList f as)’
  36.       In the type instance declaration for ‘Eval’
  37.    |
  38. 19 |     Eval (f a) ': Eval (MapList f as)
  39.  
  40. -}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement