Created
December 23, 2017 23:24
-
-
Save mbloms/9dc92fb771e027e3b831c149c4599b3c to your computer and use it in GitHub Desktop.
Tree parameterized over the root, with an arbitrary type in the child-nodes.
This file contains hidden or 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 #-} | |
import Data.List (unlines) | |
data HasEq = forall a. (Eq a, Show a) => HasEq a | |
data AnyIntegral = forall a. Integral a => Integral a | |
data AnyTree x = forall a b. (Show a, Show b) => Tree x (AnyTree a) (AnyTree b) | Nil | |
instance Show a => Show (AnyTree a) where | |
show (Tree x a b) = show (x,(a,b)) | |
show Nil = "Nil" | |
instance Show HasEq where | |
show (HasEq x) = "HasEq " ++ show x | |
--peal :: HasEq -> Int | |
peal (Integral x) = fromIntegral x |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment