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

crash when unannotated definition has type variable in sub-annotation #1639

Open
marick opened this issue Sep 6, 2017 · 2 comments
Open

Comments

@marick
Copy link

marick commented Sep 6, 2017

Here is an example:

fanOut model  =
  let
    step : (a, Int)
    step =
        ( model , 3 )
  in
    5

Deleting the let type annotation, or adding one to the function causes it to work. (In the latter case, it works whether or not the let has a type annotation.

Error text:

elm-make IVFlat/Generic/TEA.elm
[                                                  ] - 0 / 1elm-make: It looks like something went wrong with the type inference algorithm.

Unable to generalize a type variable. It is not unranked.

Elm 0.18, Mac OSX 10.11.6

For reference, the above code was binary-chopped down from this:

import Tuple

type alias Return msg model = (model, Cmd msg)
type alias Unbatched msg model = (model, List (Cmd msg))

type alias FieldUpdater msg field = msg -> field -> Return msg field

type alias Lens field model = ( model -> field, field -> model -> model )
  
-- fanOut : msg -> model -> FieldUpdater msg field -> List (Lens field model)
--       -> Return msg model
fanOut msg originalModel update accessors =
  let
    step : Lens field model -> Unbatched msg model -> Unbatched msg model
    step (getter, setter) (changingModel, cmdList) =
      let 
        (newPart, newCmd) = update msg (getter originalModel)
      in
        ( setter newPart changingModel
        , newCmd :: cmdList
        )
  in  
    accessors
      |> List.foldl step (originalModel, [])
      |> Tuple.mapSecond Cmd.batch
@process-bot
Copy link

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.

@evancz
Copy link
Member

evancz commented Dec 20, 2017

Interesting! I've never seen someone do annotations with type variables inside, but not outside.

Anyway, added to #1613

@evancz evancz closed this as completed Dec 20, 2017
@evancz evancz changed the title "Unable to generalize a type error" example : involving tuples, let type annotation crash when unannotated definition has type variable in sub-annotation Mar 6, 2018
@evancz evancz reopened this Mar 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants