Skip to content

Inconsistent error report comparing with elm - TYPE MISMATCH #114

@decioferreira

Description

@decioferreira

Describe the bug
Inconsistent error report comparing with elm

To Reproduce

module Example exposing (..)

import Html


type alias Record =
    { x1 : Int
    , x2 : Int
    , x3 : Int
    }


main =
    Just Record
        |> Maybe.map2 (|>) (Just 1)
        |> Maybe.map2 (|>) (Just 1)
        |> Maybe.map2 (|>) (Just 1)
        |> Maybe.map2 (|>) (Just 1)
        |> Debug.toString
        |> Html.text

Expected behavior

% elm make src/Example.elm        
Detected problems in 1 module.
-- TYPE MISMATCH ----------------------------------------------- src/Example.elm

This function cannot handle the argument sent through the (|>) pipe:

14|     Just Record
15|         |> Maybe.map2 (|>) (Just 1)
16|         |> Maybe.map2 (|>) (Just 1)
17|         |> Maybe.map2 (|>) (Just 1)
18|         |> Maybe.map2 (|>) (Just 1)
               ^^^^^^^^^^^^^^^^^^^^^^^
The argument is:

    Maybe Record

But (|>) is piping it to a function that expects:

    Maybe (number -> value)

Actual behavior / error output

% guida make src/Example.elm
Compiled in DEBUG mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets.
Detected problems in 1 module.
-- TYPE MISMATCH ----------------------------------------------- src/Example.elm

This expression is being used in an unexpected way:

14|>    Just Record
15|>        |> Maybe.map2 (|>) (Just 1)
16|>        |> Maybe.map2 (|>) (Just 1)
17|>        |> Maybe.map2 (|>) (Just 1)
18|>        |> Maybe.map2 (|>) (Just 1)
This `|>` value is a:

    Maybe Record -> (Maybe Record -> b) -> b

But you are trying to use it as:

    Maybe Record -> (Maybe (number -> b) -> Maybe b) -> a

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions