Skip to content

Instantly share code, notes, and snippets.

@parsonsmatt
Created January 9, 2019 06:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parsonsmatt/ac2705d985915a5ee54a3340b26c4c10 to your computer and use it in GitHub Desktop.
Save parsonsmatt/ac2705d985915a5ee54a3340b26c4c10 to your computer and use it in GitHub Desktop.
{-# LANGUAGE GADTs, DataKinds, TypeOperators #-}
data HList xs where
HNil :: HList []
(:::) :: a -> HList as -> HList (a : as)
-- error:
/home/matt/hlist.hs:4:38: error:
• Expected kind ‘* -> *’, but ‘a : as’ has kind ‘[*]’
• In the first argument of ‘HList’, namely ‘(a : as)’
In the type ‘HList (a : as)’
In the definition of data constructor ‘:::’
|
4 | (:::) :: a -> HList as -> HList (a : as)
| ^^^^^^
/home/matt/hlist.hs:4:42: error:
• Expecting one more argument to ‘as’
Expected kind ‘[*]’, but ‘as’ has kind ‘* -> *’
• In the second argument of ‘(:)’, namely ‘as’
In the first argument of ‘HList’, namely ‘(a : as)’
In the type ‘HList (a : as)’
|
4 | (:::) :: a -> HList as -> HList (a : as)
| ^^
---------------------------------------------------
{-# LANGUAGE GADTs, DataKinds, TypeOperators #-}
data HList xs where
(:::) :: a -> HList as -> HList (a : as)
HNil :: HList []
-- error:
/home/matt/hlist.hs:4:19: error:
• Expecting one more argument to ‘[]’
Expected kind ‘[*]’, but ‘[]’ has kind ‘* -> *’
• In the first argument of ‘HList’, namely ‘[]’
In the type ‘HList []’
In the definition of data constructor ‘HNil’
|
4 | HNil :: HList []
| ^^
{-# LANGUAGE GADTs, KindSignatures, DataKinds, TypeOperators #-}
data HList (xs :: [*]) where
(:::) :: a -> HList as -> HList (a : as)
HNil :: HList []
-- error:
• Expecting one more argument to ‘[]’
Expected kind ‘[*]’, but ‘[]’ has kind ‘* -> *’
• In the first argument of ‘HList’, namely ‘[]’
In the type ‘HList []’
In the definition of data constructor ‘HNil’
|
4 | HNil :: HList []
| ^^
-- i actually expected this one to work! huh.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment