Created
August 28, 2014 15:50
-
-
Save timjb/4b59a8254cc89a67311b to your computer and use it in GitHub Desktop.
Bounded Existential types in Haskell
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 #-} | |
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE ConstraintKinds #-} | |
module BoundedExistentials where | |
import GHC.Exts (Constraint) | |
class Constraint1 c where | |
type Constr1 c a :: Constraint | |
data SerializableC | |
instance Constraint1 SerializableC where | |
type Constr1 SerializableC a = (Read a, Show a) | |
data Any c k = forall s. c s => Any (k s) | |
data Any' c' k = forall s. Constr1 c' s => Any' (k s) | |
test :: Any' SerializableC [] | |
test = Any' [1,2,3] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment