Created
August 19, 2016 23:56
-
-
Save anonymous/57262e4e1009e658b97e8986a2d03d40 to your computer and use it in GitHub Desktop.
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 RankNTypes #-} | |
{-# LANGUAGE KindSignatures #-} | |
{-# LANGUAGE GADTs #-} | |
module Test where | |
data D :: * -> * -> * where | |
Refl :: D a a | |
data T :: * -> * where | |
Nil :: T a | |
Cons :: (D a e) -> (e -> a) -> T a | |
newtype CpsT a = CpsT | |
{ runCpsT :: forall r . | |
r -> -- Nil | |
(forall e . D a e -> (e -> a) -> r) -> -- Cons | |
r } | |
uncps :: CpsT a -> T a | |
uncps p = runCpsT p Nil Cons | |
main = pure () :: IO () |
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
type (_, _) d = | |
Refl : ('a, 'a) d | |
type 'a t = | |
| Nil | |
| Cons : ('a, 'e) d * ('e -> 'a) -> 'a t | |
type 'a cps_t = | |
< get : 'r . | |
'r -> (* Nil *) | |
< get : 'e . ('a, 'e) d -> ('e -> 'a) -> 'r > -> (* Cons *) | |
'r > | |
(* Error: The universal variable 'e would escape its scope *) | |
let uncps : type a . a cps_t -> a t = | |
fun p -> p # get Nil (object method get d f = Cons (d, f) end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment