-
Notifications
You must be signed in to change notification settings - Fork 28
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
Some function types generate parsing warning in markdown mode #15
Comments
This issue with tuples will likely apply to What would be a representation of tuples in JSON?
↓
? |
If I have understood correctly, we need a JSON representation that distinguishes a tuple If this is the case we cannot use simple square brackets as a list of lists is also valid elm ( // Single tuple
{
"openTuple" : "(",
"content" : [1,2],
"closeTuple" : ")"
}
// List of tuples
[ { "openTuple" : "(",
"content" : [1,2],
"closeTuple" : ")"
},
{ "openTuple" : "(",
"content" : [3,4],
"closeTuple" : ")"
}
] |
If we want our transformation to be revertible (i.e. |
To send anything over a port it has to be explicitly serialised into a JSON by the programmer. The Json.Encode package shows what is available (string, int, float, bool, null, list, array and object). Note that the tuple is not one of these (quite possibly why we have this issue). So we will need to encode ourselves as one of those types. So as you say, assuming we never need to revert, creating a list makes sense. |
Let's stick with converting Later on, we'll be able to enhance the |
Will try resolving this in the evening. |
There are still a few cases that are causing linter warnings. Specifically tuples containing ```elm {m}
boolTupleTest : ( Bool, Bool )
boolTupleTest =
( False, True )
``` ```elm {m}
functionTest : Int -> Int
functionTest n =
n + 1
``` BTW, I spotted this when running this test, which might be a useful one to add to the test suite: ```elm {l m}
type alias MyRecord =
{ intItem : Int
, strItem : String
, booItem : Bool
, lstItem : List Int
, tplItem : ( Int, Int )
, tp3Item : ( Bool, Int, String )
, tLsItem : List ( Float, Int )
, rcdItem : { nestedName : String, nestedValue : Int }
, fnItem : Int -> Int
}
```
```elm {l m}
recordTest : MyRecord
recordTest =
MyRecord 1 "two" True [ 3, 4, 5 ] ( 6, 7 ) ( False, 8, "nine" ) [ ( 1.0, 11 ), ( 1.2, 13 ) ] { nestedName = "fourteen", nestedValue = 15 } (\n -> n + 1)
``` |
Thanks for digging these out Jo. I'll add the above cases to tests during the next litvis dev session. |
I'll look at this now. |
Partially applied functions are serialized to |
Markdown output does not yet parse We can add the following to the tests: ```elm {m}
charsTest : List Char
charsTest =
[ 'a', 'b', 'c' ]
```
```elm {m}
charTupleTest : ( Char, Char )
charTupleTest =
( 'a', 'b' )
``` And modify the record test: ```elm {l m}
type alias MyRecord =
{ intItem : Int
, strItem : String
, booItem : Bool
, charItem : Char
, charItems : List Char
, charTuple : ( Char, Char )
, lstItem : List Int
, tplItem : ( Int, Int )
, tp3Item : ( Bool, Int, String )
, tLsItem : List ( Float, Int )
, rcdItem : { nestedName : String, nestedValue : Int }
, fnItem : Int -> Int
}
```
```elm {l m}
recordTest : MyRecord
recordTest =
MyRecord 1 "two" True 'X' [ 'a', 'b', 'c' ] ( 'd', 'e' ) [ 3, 4, 5 ] ( 6, 7 ) ( False, 8, "nine" ) [ ( 1.0, 11 ), ( 1.2, 13 ) ] { nestedName = "fourteen", nestedValue = 15 } (\n -> n + 1)
``` |
For the record, we still need to implement markdown output for a wider range of types.
Currently some types can generate parsing warnings. For example
generates the warning :
Could not parse "[(1,2)]" (litvis:expression-value)
highlighting the entire code block.We should also test against those examples listed in #13 and #14.
If this isn't fixable in the short term, we should probably generate a more beginner friendly and correct warning (the problem isn't with the contents of the function, but the output type of the code block) such as
Markdown output not supported for this type. Could you use 'raw' (or 'r') output instead?
The text was updated successfully, but these errors were encountered: