Last active
December 23, 2015 18:29
-
-
Save puffnfresh/6675849 to your computer and use it in GitHub Desktop.
Example of ExistentialQuantification usage inside of a data declaration.
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 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] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output is of course: