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

Exporting Union Types in Elm Syntax #523

Open
trotha01 opened this issue Feb 6, 2016 · 9 comments
Open

Exporting Union Types in Elm Syntax #523

trotha01 opened this issue Feb 6, 2016 · 9 comments

Comments

@trotha01
Copy link

trotha01 commented Feb 6, 2016

If we have a submodule with:
type Animal = Cat | Dog

we can export Cat and Dog with:
module Submodule (Animal(..)) where

and import with
import Submodule exposing (Animal(..))

Can we add something that explains this on the syntax page

@halfzebra
Copy link

It is mentioned here Elm Syntax — Modules already, but I agree, it is not explicit. The best I could think of is adding a commentary about the presence of open imports for Union Types in Modules section.

@francescortiz
Copy link

I think it should be mentioned here too: https://guide.elm-lang.org/types/union_types.html

@granmoe
Copy link

granmoe commented Mar 19, 2017

Yeah, this is mysterious to a beginner and not emphasized enough in the docs (or at least not enough that I remembered it). This github issue saved me :-)

@daniel-kun
Copy link

Glad I found this github issue, because I couldn't deduct this from Elm Syntax - Modules

@zmijunkie
Copy link

Puh I am so happy to have seen this issue... Now all my Types go into a single Types.elm

@ian-moore
Copy link

This was a good 30 minutes of headache for me... glad this issue is the first result when you google it.

@fiatjaf
Copy link

fiatjaf commented Oct 7, 2017

For anyone looking here. Export your union type with module Module exposing (UnionType(..), otherthing, etc) and import it with import Module exposing (UnionType(..)).

@downloadpizza
Copy link

For anyone looking here. Export your union type with module Module exposing (UnionType(..), otherthing, etc) and import it with import Module exposing (UnionType(..)).

I somehow knew that importing it with (..) was possible, but I didnt think of exporting for some reason. ¯_(ツ)_/¯

@tankorsmash
Copy link

This means that you can't access Dog and Cat without explicitly exposing them right? Just import Submodule isn't enough to access them it seems like.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants