Skip to content

Instantly share code, notes, and snippets.

@tel
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tel/c0efcea739f2d549df0a to your computer and use it in GitHub Desktop.
Save tel/c0efcea739f2d549df0a to your computer and use it in GitHub Desktop.
Diff impl for Either and (,)
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