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

dhall-toml: support integers #2469

Merged
merged 1 commit into from Nov 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions dhall-toml/src/Dhall/DhallToToml.hs
Expand Up @@ -265,6 +265,7 @@ toToml :: TOML -> Key -> Expr Void Void -> Either CompileError TOML
toToml toml key expr = case expr of
Core.BoolLit a -> return $ insertPrim (Toml.Value.Bool a)
Core.NaturalLit a -> return $ insertPrim (Toml.Value.Integer $ toInteger a)
Core.IntegerLit a -> return $ insertPrim (Toml.Value.Integer a)
Core.DoubleLit (DhallDouble a) -> return $ insertPrim (Toml.Value.Double a)
Core.TextLit (Core.Chunks [] a) -> return $ insertPrim (Toml.Value.Text a)
Core.App Core.None _ -> return toml
Expand Down Expand Up @@ -327,6 +328,7 @@ toToml toml key expr = case expr of
-- be represented as inline tables.
isInline v = case v of
Core.BoolLit _ -> True
Core.IntegerLit _ -> True
Core.NaturalLit _ -> True
Core.DoubleLit _ -> True
Core.TextLit _ -> True
Expand All @@ -348,6 +350,7 @@ toToml toml key expr = case expr of
toAny :: Expr Void Void -> Either CompileError Toml.AnyValue.AnyValue
toAny e = case e of
Core.BoolLit x -> rightAny $ Toml.Value.Bool x
Core.IntegerLit x -> rightAny $ Toml.Value.Integer x
Core.NaturalLit x -> rightAny $ Toml.Value.Integer $ toInteger x
Core.DoubleLit (DhallDouble x) -> rightAny $ Toml.Value.Double x
Core.TextLit (Core.Chunks [] x) -> rightAny $ Toml.Value.Text x
Expand Down
1 change: 1 addition & 0 deletions dhall-toml/src/Dhall/TomlToDhall.hs
Expand Up @@ -171,6 +171,7 @@ tomlToDhall schema toml = toDhall (Core.normalize schema) (tomlToObject toml)
tomlValueToDhall :: Expr Src Void -> Value t -> Either CompileError (Expr Src Void)
tomlValueToDhall exprType v = case (exprType, v) of
(Core.Bool , Value.Bool a ) -> Right $ Core.BoolLit a
(Core.Integer , Value.Integer a) -> Right $ Core.IntegerLit a
(Core.Natural , Value.Integer a) -> Right $ Core.NaturalLit $ fromInteger a
(Core.Double , Value.Double a ) -> Right $ Core.DoubleLit $ DhallDouble a
(Core.Text , Value.Text a ) -> Right $ Core.TextLit $ Core.Chunks [] a
Expand Down
1 change: 1 addition & 0 deletions dhall-toml/tasty/data/inline-list-schema.dhall
Expand Up @@ -3,6 +3,7 @@
, lists : List (List Natural)
, nested :
{ floats : List Double
, ints : List Integer
, moreLists : List (List Natural)
}
, nested1 :
Expand Down
1 change: 1 addition & 0 deletions dhall-toml/tasty/data/inline-list.dhall
Expand Up @@ -3,6 +3,7 @@
, lists = [[1, 2], [3, 4], [] : List Natural]
, nested =
{ floats = [1.1, 2.2]
, ints = [-5, +2]
, moreLists = [[1, 2], [3, 4], [] : List Natural]
}
, nested1 =
Expand Down
1 change: 1 addition & 0 deletions dhall-toml/tasty/data/inline-list.toml
Expand Up @@ -4,6 +4,7 @@ lists = [[1, 2], [3, 4], []]

[nested]
floats = [1.1, 2.2]
ints = [-5, 2]
moreLists = [[1, 2], [3, 4], []]

[nested1]
Expand Down