@@ -528,6 +528,7 @@ reservedNames = HashSet.fromList
528528
529529type Parser = ParsecT Void Text (State SourcePos )
530530
531+ -- This is just a @Either (Doc Void) a@
531532data Result a = Success a | Failure (Doc Void ) deriving (Show , Functor )
532533
533534parseFromFileEx :: MonadFile m => Parser a -> FilePath -> m (Result a )
@@ -540,10 +541,11 @@ parseFromFileEx p path = do
540541
541542parseFromText :: Parser a -> Text -> Result a
542543parseFromText p txt =
543- let file = " <string>"
544- in either (Failure . pretty . errorBundlePretty) Success
545- . flip evalState (initialPos file)
546- $ runParserT p file txt
544+ let file = " <string>" in
545+ either
546+ (Failure . pretty . errorBundlePretty)
547+ Success
548+ $ (`evalState` initialPos file) $ (`runParserT` file) p txt
547549
548550{- Parser.Operators -}
549551
@@ -560,11 +562,12 @@ data NOperatorDef
560562 deriving (Eq , Ord , Generic , Typeable , Data , Show , NFData )
561563
562564annotateLocation :: Parser a -> Parser (Ann SrcSpan a )
563- annotateLocation p = do
564- begin <- getSourcePos
565- res <- p
566- end <- get -- The state set before the last whitespace
567- pure $ Ann (SrcSpan begin end) res
565+ annotateLocation p =
566+ do
567+ begin <- getSourcePos
568+ end <- get -- The state set before the last whitespace
569+
570+ Ann (SrcSpan begin end) <$> p
568571
569572annotateLocation1 :: Parser (NExprF NExprLoc ) -> Parser NExprLoc
570573annotateLocation1 = fmap annToAnnF . annotateLocation
0 commit comments