Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
ozgurakgun committed Dec 6, 2023
1 parent 2625a34 commit bb03cab
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/Conjure/Language/Constant.hs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,11 @@ instance SimpleJSON Constant where
fromSimpleJSON _ (JSON.Bool b) = return (ConstantBool b)

fromSimpleJSON t@TypeInt{} x@JSON.Number{} = ConstantInt TagInt <$> fromSimpleJSON t x
fromSimpleJSON t@TypeInt{} x@JSON.String{} = ConstantInt TagInt <$> fromSimpleJSON t x
fromSimpleJSON t@(TypeInt TagInt) x@JSON.String{} = ConstantInt TagInt <$> fromSimpleJSON t x


-- fromSimpleJSON (TypeInt (TagEnum enum_type_name)) (JSON.String value) =
-- return (ConstantEnum (Name enum_type_name) [] (Name value))

fromSimpleJSON (TypeEnum enum_type_name) (JSON.String value) =
return (ConstantEnum enum_type_name [] (Name value))
Expand Down
4 changes: 2 additions & 2 deletions tests/custom/json-integration/json-enum-in/data.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"p": 3,
"ghouls": [
"ghost",
"dracula",
"zombie"
]
],
"y": "zombie"
}
2 changes: 2 additions & 0 deletions tests/custom/json-integration/json-enum-in/data.param
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
letting ghouls be new type enum {ghost, dracula, zombie}
letting y be zombie
3 changes: 2 additions & 1 deletion tests/custom/json-integration/json-enum-in/m.essence
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
given ghouls new type enum

given p : int
find x : ghouls

given y : ghouls such that x != y
6 changes: 5 additions & 1 deletion tests/custom/json-integration/json-enum-in/run.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
rm -rf conjure-output

conjure solve m.essence data.json --output-format=json --line-width=40 --copy-solutions=no --savilerow-options -O0 --number-of-solutions=all --output-format=json --solutions-in-one-file
conjure solve m.essence data.param --output-format=json --line-width=40 --copy-solutions=no --savilerow-options -O0 --number-of-solutions=all --output-format=json --solutions-in-one-file
cat conjure-output/*.solutions.json

rm -rf conjure-output/*.solutions.json

conjure solve m.essence data.json --output-format=json --line-width=40 --copy-solutions=no --savilerow-options -O0 --number-of-solutions=all --output-format=json --solutions-in-one-file
cat conjure-output/*.solutions.json

rm -rf conjure-output

0 comments on commit bb03cab

Please sign in to comment.