Skip to content

Undue Infinite type message #1241

@benzen

Description

@benzen

Doing the following produce an infinite type error.

I think we could have a much better type error for this case

import Maybe
import List

type alias Tile =  { value: Int  }

addTileToList: Tile -> Maybe (List Tile) -> Maybe (List Tile)
addTileToList tile value =
  case value of
    Nothing -> Just [tile]
    Just a -> Just (a ++ tile)

To solve this, the second advice the the infinite type wiki page help.

We just need to change this

elm
    Just a -> Just (a ++ tile)

For this

    Just a -> Just (tile::a)

Still it could be possible to give better help for this kind of cases.

Hope this help

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions