Created
January 30, 2016 14:36
-
-
Save markus1189/ed5e5ef8fdc99ab4acfb to your computer and use it in GitHub Desktop.
Haskell LightSwitch
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 GADTs #-} | |
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE DataKinds #-} | |
module LightSwitch where | |
data Power = On | Off | |
type family Toggle (a :: Power) where | |
Toggle On = Off | |
Toggle Off = On | |
data Switch (a :: Power) where | |
Switch :: Switch a | |
on :: Switch On | |
on = Switch | |
off :: Switch Off | |
off = Switch | |
toggle :: Switch a -> Switch (Toggle a) | |
toggle Switch = Switch |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment