Created
August 4, 2017 06:10
-
-
Save Porges/85f66298fcedb59f834b19884778e524 to your computer and use it in GitHub Desktop.
Ed's "pseudo-haskell" from http://comonad.com/reader/2012/mirrored-lenses/ is now compilable?
This file contains hidden or 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, PolyKinds, TupleSections, TypeFamilies, TypeFamilyDependencies #-} | |
import Data.Kind (Type) | |
type LensFamily (outer :: t -> Type) (inner :: t -> Type) = | |
forall a b f. Functor f => (inner a -> f (inner b)) -> (outer a -> f (outer b)) | |
type family Snd b a = r | r -> b a where Snd b a = (a, b) | |
type family Fst a b = r | r -> a b where Fst a b = (a, b) | |
type family Id t = r | r -> t where Id x = x | |
fstLens :: LensFamily (Snd b) Id | |
fstLens f (a, b) = (, b) <$> f a | |
sndLens :: LensFamily (Fst a) Id | |
sndLens f (a, b) = (a, ) <$> f b | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment