Skip to content

Instantly share code, notes, and snippets.

@kcsongor
Last active December 26, 2017 22:41
Show Gist options
  • Save kcsongor/0a64d4e8d016c6196757ff5d9a35ebb0 to your computer and use it in GitHub Desktop.
Save kcsongor/0a64d4e8d016c6196757ff5d9a35ebb0 to your computer and use it in GitHub Desktop.
Opening datakinds
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TypeFamilies #-}
module OpenKinds where
import GHC.TypeLits (Nat)
type family Wrap :: k -> k
type family Match (b :: Bool) :: Nat where
Match 'True = 0
Match 'False = 1
Match (w 'True) = 2
Match (w 'False) = 3
type Woo = Match (Wrap 'True)
-- = 2
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TypeFamilies #-}
module OpenKinds where
import GHC.TypeLits (Nat)
type family Wrap :: WrapTag -> k -> k
data WrapTag = WrapTag
type family Match (b :: Bool) :: Nat where
Match 'True = 0
Match 'False = 1
Match (w 'WrapTag 'True) = 2
Match (w 'WrapTag 'False) = 3
type Woo = Match (Wrap 'WrapTag 'False)
-- = 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment