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

Complier fails to recognize imported module. #906

Closed
z5h opened this Issue Sep 3, 2017 · 4 comments

Comments

Projects
None yet
5 participants
@z5h

z5h commented Sep 3, 2017

X.elm

module X exposing (X)

type X
    = X Int

Y.elm

module Y exposing (..)

import X


type Thing
    = A X.X


thingToString : Thing -> String
thingToString thing =
    case thing of
        A (X.X int) ->
            "A X int"

Error is on 2nd use of X.X in Y.elm:

Cannot find pattern X.X.
No module called X has been imported.

@process-bot

This comment has been minimized.

Show comment
Hide comment
@process-bot

process-bot Sep 3, 2017

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.

process-bot commented Sep 3, 2017

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

This comment has been minimized.

Show comment
Hide comment
@evancz

evancz Sep 3, 2017

Member

When you say exposing (X) you are only exposing the type, not the constructors. You must say exposing (X(..)) to reveal the constructors as well. This allows you to hide details if you want, and it is very important to creating strong abstractions. I recommend asking around on Slack for further details.

So there is no bug here, but that is certainly a weird error message. This is a good candidate for https://github.com/elm-lang/error-message-catalog/issues Can you put it there?

Member

evancz commented Sep 3, 2017

When you say exposing (X) you are only exposing the type, not the constructors. You must say exposing (X(..)) to reveal the constructors as well. This allows you to hide details if you want, and it is very important to creating strong abstractions. I recommend asking around on Slack for further details.

So there is no bug here, but that is certainly a weird error message. This is a good candidate for https://github.com/elm-lang/error-message-catalog/issues Can you put it there?

@evancz evancz closed this Sep 3, 2017

@martian57

This comment has been minimized.

Show comment
Hide comment
@martian57

martian57 Oct 4, 2017

I am new to elm. Exposing the constructors work, but a slight modification to the code cause the compiler to fail:

X.elm:

module X exposing (XType(..))

type XType
    = X1 Int

Y.elm:

module Y exposing (..)

import X


type Thing
    = A X.XType


thingToString : Thing -> String
thingToString thing =
    case thing of
        A (X.XType int) ->
            "A X int"

results in

Cannot find pattern `X.XType`.

13|         A (X.XType int) ->
               ^^^^^^^^^^^
`X` does not expose `XType`. 

martian57 commented Oct 4, 2017

I am new to elm. Exposing the constructors work, but a slight modification to the code cause the compiler to fail:

X.elm:

module X exposing (XType(..))

type XType
    = X1 Int

Y.elm:

module Y exposing (..)

import X


type Thing
    = A X.XType


thingToString : Thing -> String
thingToString thing =
    case thing of
        A (X.XType int) ->
            "A X int"

results in

Cannot find pattern `X.XType`.

13|         A (X.XType int) ->
               ^^^^^^^^^^^
`X` does not expose `XType`. 
@jvoigtlaender

This comment has been minimized.

Show comment
Hide comment
@jvoigtlaender

jvoigtlaender Oct 4, 2017

Contributor

Try replacing A (X.XType int) by A (X.X1 int).

Contributor

jvoigtlaender commented Oct 4, 2017

Try replacing A (X.XType int) by A (X.X1 int).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment