Skip to content

Instantly share code, notes, and snippets.

@puffnfresh
Last active December 23, 2015 18:29
Show Gist options
  • Save puffnfresh/6675849 to your computer and use it in GitHub Desktop.
Save puffnfresh/6675849 to your computer and use it in GitHub Desktop.
Example of ExistentialQuantification usage inside of a data declaration.
{-# LANGUAGE ExistentialQuantification #-}
module Kris where
data A = A
data B = B
data C = C
instance Show A where
show _ = "This is A"
instance Show B where
show _ = "B"
instance Show C where
show _ = "and C"
data Showable = forall s. Show s => Showable s
instance Show Showable where
show (Showable s) = show s
main :: IO ()
main = print [Showable A, Showable B, Showable C]
@puffnfresh
Copy link
Author

Output is of course:

[This is A,B,and C]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment