Created
October 9, 2014 02:05
-
-
Save mbrcknl/775bc638882656866301 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 Rank2Types #-} | |
type Lens s t a b = forall f. Functor f => (a -> f b) -> (s -> f t) | |
type Ref s t a b = s -> Rep a b t | |
data Rep a b t = Rep a (b -> t) | |
instance Functor (Rep a b) where | |
fmap f (Rep a g) = Rep a (f . g) | |
lens2Ref :: Lens s t a b -> Ref s t a b | |
lens2Ref r = r (\b -> Rep b id) | |
ref2Lens :: Ref s t a b -> Lens s t a b | |
ref2Lens l k x = case l x of | |
Rep s f -> fmap f (k s) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment