-
-
Save gnumonik/a321defc6ba0af9035653f5ac3693c24 to your computer and use it in GitHub Desktop.
Lift a traversal over a kind-indexed type to a traversal over a type that existentially wraps it
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
someCard :: forall b f. Applicative f | |
=> (forall f q r t. Applicative f => (b -> f b) | |
-> Card q r t | |
-> f (Card q r t)) | |
-> ((b -> f b) -> SomeCard -> f SomeCard) | |
someCard t = \_ -> h (g t) | |
where | |
g :: forall b f. Applicative f | |
=> (forall q r t . (b -> f b) -> Card q r t -> f (Card q r t)) | |
-> (forall q r t. Card q r t -> f (Card q r t)) | |
g f = f (pure . identity) | |
h :: forall f. Applicative f | |
=> (forall q r t. (Card q r t -> f (Card q r t))) | |
-> (SomeCard -> f SomeCard) | |
h f = \(MkSomeCard c) -> MkSomeCard <$> f c |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment