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

Added brackets #569

Closed
wants to merge 1 commit into from
Closed
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
20 changes: 10 additions & 10 deletions tested/languages/haskell/generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,37 +48,37 @@ def convert_value(value: Value) -> str:
return f"({convert_arguments(value.data)})"
elif isinstance(value.type, AdvancedNumericTypes):
if not isinstance(value.data, SpecialNumbers):
return f"{value.data} :: {convert_declaration(value.type)}"
return f"({value.data} :: {convert_declaration(value.type)})"
elif value.data == SpecialNumbers.NOT_A_NUMBER:
return f"(0/0) :: {convert_declaration(value.type)}"
return f"((0/0) :: {convert_declaration(value.type)})"
elif value.data == SpecialNumbers.POS_INFINITY:
return f"(1/0) :: {convert_declaration(value.type)}"
return f"((1/0) :: {convert_declaration(value.type)})"
else:
assert value.data == SpecialNumbers.NEG_INFINITY
return f"(-1/0) :: {convert_declaration(value.type)}"
return f"((-1/0) :: {convert_declaration(value.type)})"
elif value.type == AdvancedStringTypes.CHAR:
assert isinstance(value, StringType)
return "'" + value.data.replace("'", "\\'") + "'"
# Handle basic types
value = as_basic_type(value)
if value.type == BasicNumericTypes.INTEGER:
return f"{value.data} :: Int"
return f"({value.data} :: Int)"
elif value.type == BasicNumericTypes.REAL:
if not isinstance(value.data, SpecialNumbers):
return f"{value.data} :: Double"
return f"({value.data} :: Double)"
elif value.data == SpecialNumbers.NOT_A_NUMBER:
return "(0/0) :: Double"
return "((0/0) :: Double)"
elif value.data == SpecialNumbers.POS_INFINITY:
return "(1/0) :: Double"
return "((1/0) :: Double)"
else:
assert SpecialNumbers.NEG_INFINITY
return "(-1/0) :: Double"
return "((-1/0) :: Double)"
elif value.type == BasicStringTypes.TEXT:
return json.dumps(value.data)
elif value.type == BasicBooleanTypes.BOOLEAN:
return str(value.data)
elif value.type == BasicNothingTypes.NOTHING:
return "Nothing :: Maybe Integer"
return "(Nothing :: Maybe Integer)"
elif value.type == BasicSequenceTypes.SEQUENCE:
assert isinstance(value, SequenceType)
return f"[{convert_arguments(value.data)}]"
Expand Down
Loading