mirror of
https://github.com/joshuaclayton/unused.git
synced 2024-09-11 12:55:54 +03:00
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:
parent
7e3b91dc24
commit
eda4991e38
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
module Unused.Projection where
|
module Unused.Projection where
|
||||||
|
|
||||||
|
import qualified Data.Bifunctor as BF
|
||||||
import Data.Monoid ((<>))
|
import Data.Monoid ((<>))
|
||||||
import Data.Text (Text)
|
import Data.Text (Text)
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
@ -15,7 +16,7 @@ data ParsedTransform = ParsedTransform
|
|||||||
, ptPost :: Text
|
, ptPost :: Text
|
||||||
}
|
}
|
||||||
|
|
||||||
translate :: Text -> Either ParseError (Text -> Text)
|
translate :: Text -> Either String (Text -> Text)
|
||||||
translate template = applyTransform <$> parseTransform template
|
translate template = applyTransform <$> parseTransform template
|
||||||
|
|
||||||
applyTransform :: ParsedTransform -> Text -> Text
|
applyTransform :: ParsedTransform -> Text -> Text
|
||||||
@ -24,8 +25,8 @@ applyTransform pt t =
|
|||||||
<> runTransformations t (ptTransforms pt)
|
<> runTransformations t (ptTransforms pt)
|
||||||
<> ptPost pt
|
<> ptPost pt
|
||||||
|
|
||||||
parseTransform :: Text -> Either ParseError ParsedTransform
|
parseTransform :: Text -> Either String ParsedTransform
|
||||||
parseTransform = parse parsedTransformParser ""
|
parseTransform = BF.first show . parse parsedTransformParser ""
|
||||||
|
|
||||||
parsedTransformParser :: Parser ParsedTransform
|
parsedTransformParser :: Parser ParsedTransform
|
||||||
parsedTransformParser =
|
parsedTransformParser =
|
||||||
|
@ -66,7 +66,7 @@ instance FromJSON TermAlias where
|
|||||||
parseJSON (Y.Object o) = TermAlias
|
parseJSON (Y.Object o) = TermAlias
|
||||||
<$> o .: "from"
|
<$> o .: "from"
|
||||||
<*> o .: "to"
|
<*> o .: "to"
|
||||||
<*> (either (fail . show) return =<< (translate . T.pack <$> (o .: "to")))
|
<*> (either fail return =<< (translate . T.pack <$> (o .: "to")))
|
||||||
parseJSON _ = M.mzero
|
parseJSON _ = M.mzero
|
||||||
|
|
||||||
data MatchHandler a = MatchHandler
|
data MatchHandler a = MatchHandler
|
||||||
|
Loading…
Reference in New Issue
Block a user