Add type-specialized versions of Applicative operators #13

Closed
ygale opened this Issue Mar 28, 2012 · 0 comments

Projects

None yet

2 participants

@ygale

The attoparsec-text package provides the type-specialized versions of (*>) and (<*). These make it possible to use the IsString instances of Parser to write parsers using nice syntax like:

 "Shoe size: " .*> decimal

Currently code using attoparsec-text with that technique cannot be ported to attoparsec without seriouse breakage.

In Data.Attoparsec.Text:

-- | Type-specialized version of '*>' for 'Text'.
(.*>) :: Applicative f => Text -> f a -> f a
(.*>) = (*>)

-- | Type-specialized version of '<*' for 'Text'.
(<*.) :: Applicative f => f a -> Text -> f a
(<*.) = (<*)

In Data.Attoparsec.ByteString:

-- | Type-specialized version of '*>' for 'ByteString'.
(.*>) :: Applicative f => ByteString -> f a -> f a
(.*>) = (*>)

-- | Type-specialized version of '<*' for 'ByteString'.
(<*.) :: Applicative f => f a -> ByteString -> f a
(<*.) = (<*)
@bos bos added a commit that closed this issue May 28, 2012
@bos Add type-specialized .*> and <*. combinators
This should resolve gh-13.
c5ffb6c
@bos bos closed this in c5ffb6c May 28, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment