halohalospecial / atom-elmjutsu

A bag of tricks for developing with Elm. (Atom package)
https://atom.io/packages/elmjutsu
MIT License
192 stars 24 forks source link

Imports of union types cause issues with insertion of case/of statements #78

Open danheuck opened 7 years ago

danheuck commented 7 years ago

Importing a union type from a module (in all ways but one) either breaks insertion of case/of statements, or inserts case/of statements that will not function.

For an example, if I have this module:

module Exporter exposing (..)

type Test
    = Test1
    | Test2

And I import it with import Exporter exposing (Test(..)) or import Exporter exposing (Test(Test1, Test2)) The case/of insertion will not be provided.

If on the other hand I import with import Exporter exposing (Test) or import Exporter Then the insertion will be provided as

case test of
      Test1 ->
      Test2 ->

Which will not work because Test1 and Test2 aren't imported.

The only way to make this setup work is to import exposing everything import Exporter exposing (..)

If this cannot be fixed easily, then perhaps giving the option to insert case/of statements using the qualified name of the constructors could be provided (since qualified imports are officially preferred anyway)? e.g.

case test of
      Exporter.Test1 ->
      Exporter.Test2 ->