Last active
February 9, 2022 14:01
-
-
Save Gurkenglas/137914f5790f0e0390c631f9678832da to your computer and use it in GitHub Desktop.
forallgadts
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 GADTs, RankNTypes #-} | |
data Foo a where | |
Bar :: Int -> Foo Int | |
Baz :: String -> Foo String | |
newtype Foo2 a = Foo2 {runFoo2 :: forall f. (Int -> f Int) -> (String -> f String) -> f a} | |
foo2s :: Foo2 String | |
foo2s = Foo2 $ \bar baz -> baz "asd" |
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 #-} | |
newtype Stream a = Stream {runStream :: forall f. (a -> f a -> f a) -> f a} | |
fromn :: Int -> Stream Int | |
fromn n = Stream $ \c -> c n $ runStream (fromn (n+1)) c | |
tolist :: Stream a -> [a] | |
tolist s = runStream s (:) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment