Permalink
Browse files

Use (<$>)

- Suggestion by Martijn van Steenbergen
  • Loading branch information...
1 parent 9cc6419 commit c1c54c5468d856c3976022290c34ff1ebb15dc85 @spl committed Jun 26, 2009
Showing with 4 additions and 3 deletions.
  1. +4 −3 src/Text/XFormat/Read.hs
View
7 src/Text/XFormat/Read.hs
@@ -74,6 +74,7 @@ module Text.XFormat.Read (
--------------------------------------------------------------------------------
+import Control.Applicative ((<$>))
import Text.ParserCombinators.ReadP
import Data.Char (isSpace)
@@ -289,23 +290,23 @@ instance (Format d a) => Format (MaybeF d) (Maybe a) where
data ChoiceF a = Choice [a]
instance (Format d a) => Format (ChoiceF d) a where
- readpf (Choice ds) = choice (fmap readpf ds)
+ readpf (Choice ds) = choice (readpf <$> ds)
-- | Parse one of two formats in a fully symmetric choice.
data EitherF a b = Either a b
instance (Format d1 a1, Format d2 a2) => Format (EitherF d1 d2) (Either a1 a2) where
readpf (Either d1 d2) =
- (readpf d1 >>= return . Left) +++ (readpf d2 >>= return . Right)
+ (Left <$> readpf d1) +++ (Right <$> readpf d2)
-- | Parse one of two formats, trying the left one first.
data EitherLF a b = EitherL a b
instance (Format d1 a1, Format d2 a2) => Format (EitherLF d1 d2) (Either a1 a2) where
readpf (EitherL d1 d2) =
- (readpf d1 >>= return . Left) <++ (readpf d2 >>= return . Right)
+ (Left <$> readpf d1) <++ (Right <$> readpf d2)
--------------------------------------------------------------------------------

0 comments on commit c1c54c5

Please sign in to comment.