Last active
October 14, 2021 18:45
-
-
Save jmatsushita/11a6aeac997f56e2d3572499bb2f9707 to your computer and use it in GitHub Desktop.
Existential types with constraints
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
module Main where | |
import Prelude | |
newtype AnyShow = AnyShow (forall r. (forall a. Show a => a -> r) -> r) | |
mkAnyShow :: forall a. Show a => a -> AnyShow | |
mkAnyShow a = AnyShow (_ $ a) | |
elimAnyShow :: forall r. (forall a. Show a => a -> r) -> AnyShow -> r | |
elimAnyShow f (AnyShow a) = f a | |
instance Show AnyShow where | |
show (AnyShow a) = a show |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment