elm-lang / elm-make

A build tool for Elm projects
BSD 3-Clause "New" or "Revised" License
175 stars 45 forks source link

elm-make: type applications should start with a type atom #144

Closed Zimmi48 closed 7 years ago

Zimmi48 commented 7 years ago

It seems that this error was reported before but not for 0.18. I did not try to minimize the faulty code (no time for that). I hope the error report is useful nonetheless. The code here makes elm-make crash with the following error message:

-- TYPE MISMATCH -------------------------------------------------- src/Game.elm

The right side of (|>) is causing a type mismatch.

200|                             { answer = questionState.answer |> removeFromAnswer }
201|>                                |> Active

(|>) is expecting the right side to be a:

    { ... } -> a

But the right side is:

    elm-make: type applications should start with a type atom
CallStack (from HasCallStack):
  error, called at src/Reporting/Render/Type.hs:411:9 in elm-compiler-0.18-8FVx3ZbYiisIpZXxx99S4A:Reporting.Render.Type

EDIT: for the record I'm using Linux (NixOS) but I hope the error is not specific to this OS.

process-bot commented 7 years ago

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.

Zimmi48 commented 7 years ago

I've minimized the example to this:

type X a = X Int

v = if True then X 0 else { x = 0 }

f : X -> ()
f { x } = ()

The error report is the following:

-- TYPE MISMATCH ------------------------------------------------------- Bug.elm

The branches of this `if` produce different types of values.

3| v = if True then X 0 else { x = 0 }
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The `then` branch has type:

    elm-make: type applications should start with a type atom
CallStack (from HasCallStack):
  error, called at src/Reporting/Render/Type.hs:411:9 in elm-compiler-0.18-8FVx3ZbYiisIpZXxx99S4A:Reporting.Render.Type

One can reproduce this on elm-lang.org/try but the error message is cut.

seurimas commented 7 years ago

This is likely issue elm-complier#1373.

Additional note to googlers: I ran into this same root issue because I was not specifying a complete type (e.g. "f : X -> ()" is incorrect above, as it should be "f : X a -> ()")

Zimmi48 commented 7 years ago

You mean elm-lang/elm-compiler#1373.