Last active
August 29, 2015 14:05
-
-
Save tel/c0efcea739f2d549df0a to your computer and use it in GitHub Desktop.
Diff impl for Either and (,)
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
data Zipper t a = Zipper { diff :: D t a, here :: a } | |
deriving instance Diff t => Functor (Zipper t) | |
class (Functor t, Functor (D t)) => Diff t where | |
data D t :: * -> * | |
inTo :: t a -> t (Zipper t a) | |
outOf :: Zipper t a -> t a | |
instance Diff ((,) x) where | |
data D ((,) x) a = DReader x deriving Functor | |
inTo (x, a) = (x, Zipper (DReader x) a) | |
outOf (Zipper (DReader x) a) = (x, a) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment