Last active
December 26, 2017 22:41
-
-
Save kcsongor/0a64d4e8d016c6196757ff5d9a35ebb0 to your computer and use it in GitHub Desktop.
Opening datakinds
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# 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