Skip to content

Commit 0b924b8

Browse files
authored
Improve readability (#47)
Use `fmap f` instead of `either Left (Right . f)` in a number of places.
1 parent ae00c8b commit 0b924b8

File tree

1 file changed

+7
-7
lines changed
  • haskell-src-meta/src/Language/Haskell/Meta

1 file changed

+7
-7
lines changed

haskell-src-meta/src/Language/Haskell/Meta/Parse.hs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,20 @@ import Language.Haskell.TH.Syntax hiding (Extension (..))
4343
-- * template-haskell
4444

4545
parsePat :: String -> Either String Pat
46-
parsePat = either Left (Right . toPat) . parseHsPat
46+
parsePat = fmap toPat . parseHsPat
4747

4848
parseExp :: String -> Either String Exp
49-
parseExp = either Left (Right . toExp) . parseHsExp
49+
parseExp = fmap toExp . parseHsExp
5050

5151
parseType :: String -> Either String Type
52-
parseType = either Left (Right . toType) . parseHsType
52+
parseType = fmap toType . parseHsType
5353

5454
parseDecs :: String -> Either String [Dec]
55-
parseDecs = either Left (Right . toDecs) . parseHsDecls
55+
parseDecs = fmap toDecs . parseHsDecls
5656

5757
-- | @since 0.8.2
5858
parseDecsWithMode :: ParseMode -> String -> Either String [Dec]
59-
parseDecsWithMode parseMode = either Left (Right . toDecs)
59+
parseDecsWithMode parseMode = fmap toDecs
6060
. parseHsDeclsWithMode parseMode
6161

6262
-----------------------------------------------------------------------------
@@ -93,12 +93,12 @@ parseHsModule :: String -> Either String (Hs.Module Hs.SrcSpanInfo)
9393
parseHsModule = parseResultToEither . parseModuleWithMode myDefaultParseMode
9494

9595
parseHsDecls :: String -> Either String [Hs.Decl Hs.SrcSpanInfo]
96-
parseHsDecls = either Left (Right . moduleDecls)
96+
parseHsDecls = fmap moduleDecls
9797
. parseResultToEither . parseModuleWithMode myDefaultParseMode
9898

9999
-- | @since 0.8.2
100100
parseHsDeclsWithMode :: ParseMode -> String -> Either String [Hs.Decl Hs.SrcSpanInfo]
101-
parseHsDeclsWithMode parseMode = either Left (Right . moduleDecls)
101+
parseHsDeclsWithMode parseMode = fmap moduleDecls
102102
. parseResultToEither . parseModuleWithMode parseMode
103103

104104

0 commit comments

Comments
 (0)