-
Notifications
You must be signed in to change notification settings - Fork 7
Fix/tested haskell judge #543
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
Open
tibvdm
wants to merge
5
commits into
master
Choose a base branch
from
fix/tested-haskell-judge
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7df8f0d
Allow Heterogenous arguments in Haskell to allow Ambiguous variable j…
tibvdm ae51fae
add parentheses to fix explicit typing + remove explicit typing in fe…
tibvdm 41bade5
fix linting and typing errors
tibvdm b33c1d3
remove print statement from config + fix haskell test
tibvdm b20c4c1
fix linter
tibvdm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,3 +82,4 @@ venv-*/ | |
.venv/ | ||
node_modules/ | ||
result/ | ||
.data/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,37 +48,37 @@ def convert_value(value: Value) -> str: | |
return f"({convert_arguments(value.data)})" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is where I would remove the typing information. But i am not an expert on TESTed nor haskell so I am not sure it will work |
||
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)}]" | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
tabs: | ||
- tab: geefNde (Int) | ||
testcases: | ||
- expression: geefNde(0, [1, 2, 3, 4, 5]) | ||
return: 1 | ||
- expression: geefNde(1, [1, 2, 3, 4, 5]) | ||
return: 2 | ||
- expression: geefNde(2, [1, 2, 3, 4, 5]) | ||
return: 3 | ||
- expression: geefNde(3, [1, 2, 3, 4, 5]) | ||
return: 4 | ||
- expression: geefNde(4, [1, 2, 3, 4, 5]) | ||
return: 5 | ||
|
||
- tab: geefNde (Double) | ||
testcases: | ||
- expression: geefNde(0, [1.0, 2.0, 3.0, 4.0, 5.0]) | ||
return: 1.0 | ||
- expression: geefNde(1, [1.0, 2.0, 3.0, 4.0, 5.0]) | ||
return: 2.0 | ||
- expression: geefNde(2, [1.0, 2.0, 3.0, 4.0, 5.0]) | ||
return: 3.0 | ||
- expression: geefNde(3, [1.0, 2.0, 3.0, 4.0, 5.0]) | ||
return: 4.0 | ||
- expression: geefNde(4, [1.0, 2.0, 3.0, 4.0, 5.0]) | ||
return: 5.0 | ||
|
||
- tab: geefNde (Char) | ||
testcases: | ||
- expression: geefNde(0, ['a', 'b', 'c', 'd', 'e']) | ||
return: a | ||
- expression: geefNde(1, ['a', 'b', 'c', 'd', 'e']) | ||
return: b | ||
- expression: geefNde(2, ['a', 'b', 'c', 'd', 'e']) | ||
return: c | ||
- expression: geefNde(3, ['a', 'b', 'c', 'd', 'e']) | ||
return: d | ||
- expression: geefNde(4, ['a', 'b', 'c', 'd', 'e']) | ||
return: e | ||
|
||
- tab: geefNde (Tuple) | ||
testcases: | ||
- expression: geefNde(0, [(1, 5), (2, 4), (3, 3), (4, 2), (5, 1)]) | ||
return: [1, 5] | ||
- expression: geefNde(1, [(1, 5), (2, 4), (3, 3), (4, 2), (5, 1)]) | ||
return: [2, 4] | ||
- expression: geefNde(2, [(1, 5), (2, 4), (3, 3), (4, 2), (5, 1)]) | ||
return: [3, 3] | ||
- expression: geefNde(3, [(1, 5), (2, 4), (3, 3), (4, 2), (5, 1)]) | ||
return: [4, 2] | ||
- expression: geefNde(4, [(1, 5), (2, 4), (3, 3), (4, 2), (5, 1)]) | ||
return: [5, 1] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
tabs: | ||
- tab: 'voorlaatste (Int)' | ||
testcases: | ||
- expression: voorlaatste([1, 2]) | ||
return: 1 | ||
- expression: voorlaatste([1, 2, 3]) | ||
return: 2 | ||
- expression: voorlaatste([1, 2, 3, 4]) | ||
return: 3 | ||
- expression: voorlaatste([1, 2, 3, 4, 5]) | ||
return: 4 | ||
- expression: voorlaatste([1, 0, 1, 0, 1]) | ||
return: 0 | ||
- expression: voorlaatste([9, 81, 1, 2, 4, 1, 42, 1]) | ||
return: 42 | ||
- tab: 'voorlaatste (Double)' | ||
testcases: | ||
- expression: voorlaatste([1.0, 2.0]) | ||
return: 1.0 | ||
- expression: voorlaatste([1.0, 2.0, 3.0]) | ||
return: 2.0 | ||
- expression: voorlaatste([1.0, 2.0, 3.0, 4.0]) | ||
return: 3.0 | ||
- expression: voorlaatste([1.0, 2.0, 3.0, 4.0, 5.0]) | ||
return: 4.0 | ||
- expression: voorlaatste([1.0, 0.0, 1.0, 0.0, 1.0]) | ||
return: 0.0 | ||
- expression: voorlaatste([9.0, 81.0, 1.0, 2.0, 4.0, 1.0, 42.0, 1.0]) | ||
return: 42.0 | ||
- tab: 'voorlaatste (Char)' | ||
testcases: | ||
- expression: voorlaatste(['a', 'b']) | ||
return: 'a' | ||
- expression: voorlaatste(['a', 'b', 'c']) | ||
return: 'b' | ||
- expression: voorlaatste(['a', 'b', 'c', 'd']) | ||
return: 'c' | ||
- expression: voorlaatste(['a', 'b', 'c', 'd', 'e']) | ||
return: 'd' | ||
- expression: voorlaatste(['a', 'b', 'a', 'b', 'a']) | ||
return: 'b' | ||
- expression: voorlaatste(['c', 'd', 'a', 'b', 'g']) | ||
return: 'b' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
geefNde :: Int -> [a] -> a | ||
geefNde n l = l !! n |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
voorlaatste :: [a] -> a | ||
voorlaatste = last . init |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be a constant instead of a variable,
So
CLEAN_TYPES_REGEX =
Also is this regex completly save? Eg is it possible that it also matches a type expression within a string?
If typing is optional, it would probably be better not to add the type declarations in 'generators.py', instead of adding them there, running the tests with typing and then obfuscating those types to the end user.