Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor bug fixes for yaml-to-dhall error messages #1305

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions dhall-json/src/Dhall/JSONToDhall.hs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@ import qualified Options.Applicative as O
import Options.Applicative (Parser)

import Dhall.JSON.Util (pattern V)
import qualified Dhall
import qualified Dhall.Core as D
import Dhall.Core (Expr(App), Chunks(..))
import qualified Dhall.Import
Expand Down Expand Up @@ -480,9 +479,9 @@ dhallFromJSON (Conversion {..}) expressionType =

-- number ~> Natural
loop D.Natural (A.Number x)
| Right n <- floatingOrInteger x :: Either Double Dhall.Natural
| Right n <- floatingOrInteger x :: Either Double Integer
, n >= 0
= Right (D.NaturalLit n)
= Right (D.NaturalLit (fromInteger n))
| otherwise
= Left (Mismatch D.Natural (A.Number x))

Expand Down Expand Up @@ -645,7 +644,7 @@ showCompileError format showValue = let prefix = red "\nError: "
where sep = red "\n--------\n" :: Text

Mismatch e v -> prefix
<> "Dhall type expression and json value do not match:"
<> "Dhall type expression and " <> format <> " value do not match:"
<> "\n\nExpected Dhall type:\n" <> showExpr e
<> "\n\n" <> format <> ":\n" <> showValue v
<> "\n"
Expand Down