Created
March 4, 2013 06:45
-
-
Save luqui/5080462 to your computer and use it in GitHub Desktop.
GeneralizedNewtypeDeriving and GADT interaction
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, GeneralizedNewtypeDeriving #-} | |
data Switch b a where | |
SwitchA :: Switch b A | |
SwitchB :: b -> Switch b B | |
class Switchable c where | |
switch :: c -> Switch b c | |
data A = A | |
instance Switchable A where | |
switch A = SwitchA | |
newtype B = B A | |
deriving (Switchable) | |
unSwitchB :: Switch b B -> b | |
unSwitchB (SwitchB y) = y | |
inconsistent :: b | |
inconsistent = unSwitchB (switch (B A)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment