Compiler: List without any type compiles in Union Type

Created on 27 Sep 2017  路  7Comments  路  Source: elm/compiler

v.0.18.0
I had a Union Type defined like:

type Test = T1 List String | T2 String

and T1 evaluated to:
<function> : List -> String -> Test

I now know that what I meant was:
type Test = T1 (List String) | T2 String

but should <function> : List -> String -> Test have been possible?

Most helpful comment

I added this to the #1373 meta issue. In the past week or so I fixed the "no kind checking" by requiring that all types are used fully. So you can say Maybe a but you cannot say Maybe by itself. You can say Result x Int but you cannot say type Abc = Xyz (Result x) Int or weird stuff like that.

All 7 comments

Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.

For organizational purposes: Related to #1598

As for your question: I'm not sure what the eventual intention is. Either the compiler makes it impossible to represent * -> * types, or, it comes fully supported. Currently, we're somewhere in between: one can have the type, but not alias it, nor construct a value of that type.

I'm not sure if this is related or not but the following (invalid) code successfully compiles:

x : List List Int
x = Debug.crash "foo"

This compiles fine too:

x : Dict Maybe List
x = Dict.empty

https://ellie-app.com/d26YftK8ma1/0 - no compile or even runtime errors with Dict.empty : Dict Maybe List

Those are cases of "no kind checking", tracked in this meta issue

I added this to the #1373 meta issue. In the past week or so I fixed the "no kind checking" by requiring that all types are used fully. So you can say Maybe a but you cannot say Maybe by itself. You can say Result x Int but you cannot say type Abc = Xyz (Result x) Int or weird stuff like that.

In the development build it looks like this:

-- TOO FEW ARGS ------------------------------------------------------- temp.elm

The `List` type was given 0 arguments:

9| type Test = T1 List String | T2 String
                  ^^^^
But it needs 1 argument. What is missing? Are some parentheses misplaced?

Thank you for the report!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ShalokShalom picture ShalokShalom  路  3Comments

kuon picture kuon  路  3Comments

ccapndave picture ccapndave  路  3Comments

maxsnew picture maxsnew  路  3Comments

maxsnew picture maxsnew  路  4Comments