Open
Description
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