[elm-discuss] Re: How to order imports?

2016-09-02 Thread Magnus Rundberget
Haha funny this question popped up here now.

Yesterday I was implementing a "sort imports" feature for elm-light (Elm 
plugin for Light Table). I was pondering the same thing.
Ended up implementing it like this:
- Project modules first (sorted alphabetically)
- The External modules sorted alphabetically

I guess I need to make this configurable until a de-facto std emerges.


An easy option would be if elm-format did it, but elm-format doesn't to the 
best of my knowledge (and IMHO shouldn't have to) have knowledge about your 
project. So sorting alpahbetically no problem.

I'd vote for something simple, you probably won't and shouldn't have a ton 
of imports in a module anyway.







On Friday, 2 September 2016 01:54:35 UTC+2, John Bugner wrote:
>
> Is there a "right" (de-jure or de-facto) way to order imports? If not, 
> then how do you order them?
>
> As I see it, there's two kinds of imports:
> (1) local imports (Main, Engine, EnginePart, etc)
> (2) and standard imports (List, Dict, Maybe, etc)
>
> I put the local imports first, then an empty line, then the standard 
> imports.
>
> And, is there a right way to order each import within its set? That is, 
> should one try to "logically" order them, like having 'import List' come 
> before 'import Array', because the former is more "basic" than the latter? 
> Or should they just be in alphabetical order?
>
> I prefer to logically order imports; I try to order them consistently in 
> every project, but it doesn't always happen.
>
>

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[elm-discuss] Re: How to order imports?

2016-09-02 Thread Charlie Koster
I really wish elm-format re-ordered imports so that I didn't have to care 
and it'd be consistent internal to my project and across community projects 
that use elm-format.

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[elm-discuss] Re: How to order imports?

2016-09-02 Thread Wouter In t Velt
Good question to raise! The lack of any logic in my own imports had on 
occasion nagged me too.

This is our convention:
>
> 1) Core modules;
> 2) Public modules from elm-lang;
> 3) Other public modules;
> 4) Project modules.
>

The one @Simone Vittori suggests looks simple and workable.

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[elm-discuss] Re: How to order imports?

2016-09-02 Thread Simone Vittori
At my company we have our own conventions, which are always good to have I 
think, even though the order doesn't really matter in this case.

This is our convention:

1) Core modules;
2) Public modules from elm-lang;
3) Other public modules;
4) Project modules.

Anyway I see you mentioned List and Maybe. These are not necessary to 
import as they're part of the default imports 

.

On Friday, 2 September 2016 00:54:35 UTC+1, John Bugner wrote:
>
> Is there a "right" (de-jure or de-facto) way to order imports? If not, 
> then how do you order them?
>
> As I see it, there's two kinds of imports:
> (1) local imports (Main, Engine, EnginePart, etc)
> (2) and standard imports (List, Dict, Maybe, etc)
>
> I put the local imports first, then an empty line, then the standard 
> imports.
>
> And, is there a right way to order each import within its set? That is, 
> should one try to "logically" order them, like having 'import List' come 
> before 'import Array', because the former is more "basic" than the latter? 
> Or should they just be in alphabetical order?
>
> I prefer to logically order imports; I try to order them consistently in 
> every project, but it doesn't always happen.
>
>

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.