Skip to content

Instantly share code, notes, and snippets.

@luqui
Created March 4, 2013 06:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luqui/5080462 to your computer and use it in GitHub Desktop.
Save luqui/5080462 to your computer and use it in GitHub Desktop.
GeneralizedNewtypeDeriving and GADT interaction
{-# 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