Skip to content

Commit

Permalink
Add a Profunctor instance
Browse files Browse the repository at this point in the history
Hopefully it's valid.
  • Loading branch information
treeowl committed Aug 22, 2015
1 parent c753d35 commit fbb6f1c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Text/Trifecta/Util/It.hs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import Control.Monad
import Data.Semigroup
import Data.ByteString as Strict
import Data.ByteString.Lazy as Lazy
import Data.Profunctor
import Text.Trifecta.Rope
import Text.Trifecta.Delta
import Text.Trifecta.Util.Combinators as Util
Expand All @@ -47,6 +48,11 @@ instance Show a => Show (It r a) where
instance Functor (It r) where
fmap f (Pure a) = Pure $ f a
fmap f (It a k) = It (f a) $ fmap f . k

instance Profunctor It where
rmap = fmap
lmap f (Pure a) = Pure a
lmap f (It a g) = It a (lmap f . g . f)

instance Applicative (It r) where
pure = Pure
Expand Down

0 comments on commit fbb6f1c

Please sign in to comment.