Given issues with ParseError type, cast to String first

When installing 0.6.0.0 via Homebrew, a compilation error is shown:

    src/Unused/Projection.hs:27:34: error:
        • Expecting two more arguments to ‘ParseError’
          Expected a type, but ‘ParseError’ has kind ‘* -> * -> *’
        • In the first argument of ‘Either’, namely ‘ParseError’
          In the type signature:
            parseTransform :: Text -> Either ParseError ParsedTransform
    cabal: Leaving directory '.'
    cabal: Error: some packages failed to install:
    unused-0.6.0.0 failed during the building phase. The exception was:
    ExitFailure 1

Given we're rendering the output as a string with `show`, this moves
`show` to where we parse and pass the `String` around instead.
This commit is contained in:
Joshua Clayton 2016-07-19 22:25:56 -04:00
parent 7e3b91dc24
commit eda4991e38
No known key found for this signature in database
GPG Key ID: 5B6558F77E9A8118
2 changed files with 5 additions and 4 deletions

View File

@ -2,6 +2,7 @@
module Unused.Projection where
import qualified Data.Bifunctor as BF
import Data.Monoid ((<>))
import Data.Text (Text)
import qualified Data.Text as T
@ -15,7 +16,7 @@ data ParsedTransform = ParsedTransform
, ptPost :: Text
}
translate :: Text -> Either ParseError (Text -> Text)
translate :: Text -> Either String (Text -> Text)
translate template = applyTransform <$> parseTransform template
applyTransform :: ParsedTransform -> Text -> Text
@ -24,8 +25,8 @@ applyTransform pt t =
<> runTransformations t (ptTransforms pt)
<> ptPost pt
parseTransform :: Text -> Either ParseError ParsedTransform
parseTransform = parse parsedTransformParser ""
parseTransform :: Text -> Either String ParsedTransform
parseTransform = BF.first show . parse parsedTransformParser ""
parsedTransformParser :: Parser ParsedTransform
parsedTransformParser =

View File

@ -66,7 +66,7 @@ instance FromJSON TermAlias where
parseJSON (Y.Object o) = TermAlias
<$> o .: "from"
<*> o .: "to"
<*> (either (fail . show) return =<< (translate . T.pack <$> (o .: "to")))
<*> (either fail return =<< (translate . T.pack <$> (o .: "to")))
parseJSON _ = M.mzero
data MatchHandler a = MatchHandler