Skip to content

Instantly share code, notes, and snippets.

@jjant
Last active March 17, 2019 01:16
Show Gist options
  • Save jjant/7f77fb276e3e71ecb3b88659e67dc517 to your computer and use it in GitHub Desktop.
Save jjant/7f77fb276e3e71ecb3b88659e67dc517 to your computer and use it in GitHub Desktop.
{-# LANGUAGE TypeOperators, GADTs, DataKinds, KindSignatures #-}
import Data.Kind (Type)
data HList :: [Type] -> Type where
Empty :: HList []
HCons :: t -> HList ts -> HList (t ': ts)
myTuple2 :: HList '[Int, String] -- Analogous to (Int, String)
myTuple2 = HCons 2 (HCons "Hi!" Empty)
myTuple3 :: HList '[Bool, Int, Int -> Int] -- Analogous to (Bool, Int, Int -> Int)
myTuple3 = HCons True (HCons 1 (HCons (\x -> x + 2) Empty))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment