Skip to content

Commit

Permalink
Add functorish instances for FocusingFree
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean Hunt committed Apr 11, 2016
1 parent db8b642 commit b38d370
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/Control/Lens/Internal/Zoom.hs
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,20 @@ instance Applicative (k (Err e s)) => Applicative (FocusingErr e k s) where
-- 'Control.Monad.Trans.FreeT'
newtype FocusingFree f m k s a = FocusingFree { unfocusingFree :: k (FreeF f s (FreeT f m s)) a }

instance Functor (k (FreeF f s (FreeT f m s))) => Functor (FocusingFree f m k s) where
fmap f (FocusingFree as) = FocusingFree (fmap f as)
{-# INLINE fmap #-}

instance Apply (k (FreeF f s (FreeT f m s))) => Apply (FocusingFree f m k s) where
FocusingFree kf <.> FocusingFree ka = FocusingFree (kf <.> ka)
{-# INLINE (<.>) #-}

instance Applicative (k (FreeF f s (FreeT f m s))) => Applicative (FocusingFree f m k s) where
pure = FocusingFree . pure
{-# INLINE pure #-}
FocusingFree kf <*> FocusingFree ka = FocusingFree (kf <*> ka)
{-# INLINE (<*>) #-}

-----------------------------------------------------------------------------
--- Effect
-------------------------------------------------------------------------------
Expand Down

0 comments on commit b38d370

Please sign in to comment.