[Haskell-cafe] Imports at bottom, why not?

Clark Gaebel cgaebel at uwaterloo.ca
Tue Apr 22 19:12:49 UTC 2014


How did this work out in other languages which have imports at the bottom?

  - Clark


On Tue, Apr 22, 2014 at 3:07 PM, Thiago Negri <evohunz at gmail.com> wrote:

> Just to get things clear...
> I'm not saying that folding is a bad thing.
> But it is not a valid reason to invalidate a "import at bottom" feature.
>
> It's like saying that if you shouldn't care if you have a broken leg, just
> grab a crutch and you are good to go: "don't bother going to a
> physiotherapist."
>
> The code analysis situations are valid reasons, but I still prefer the
> language to be easier to man than to machine. Adding them at the bottom
> would incur an absurd overhead? You don't need to scan the file looking for
> imports, you can scan bottom-up the same way you would scan top-down. Or
> would you need a "do-nothing-scan" to find the end of file? (Sorry, I lack
> knowledge in file system implementations.)
>
> I browse a lot of code on github, and I don't find a way to fold import
> statements on the website.
>
>
>
> 2014-04-22 15:48 GMT-03:00 Mike Meyer <mwm at mired.org>:
>
> In that case, there is no language that is "good enough", because liking
>> code folding is language agnostic.
>>
>> Personally, I like imports at the top, as they let me know what functions
>> I can expect to find in the module. At least, if used properly. Which shows
>> the real problem with this suggestion: some modules will have imports at
>> the top and some at the bottom, so if you're looking at the middle of the
>> module and want to check on them, you've got to guess where they are.
>>
>> Frankly, if the goal is to get them out of the way, I'd rather see "local
>> imports" in a where or in clause, so you can add them to the expression
>> that needs them. But that has little enough utility that I'd rather not do
>> it, either. Hmm, maybe only in the "import Module (thing ...)" form? Nah.
>>
>>
>> On Tue, Apr 22, 2014 at 1:18 PM, Thiago Negri <evohunz at gmail.com> wrote:
>>
>>> The desired editor features are written in the haskell spec?
>>> I'm talking about the language in an editor/IDE agnostic way.
>>> If the IDE/editor is hiding it for you, it is because the language
>>> failed to be good enough to be "out of the way".
>>> So, I guess this is a +1.
>>>
>>>
>>>
>>>
>>> 2014-04-22 15:04 GMT-03:00 Ben Foppa <benjamin.foppa at gmail.com>:
>>>
>>>> Why not have an editor that collapses them?
>>>>
>>>>
>>>> On Tue, Apr 22, 2014 at 1:59 PM, Thiago Negri <evohunz at gmail.com>wrote:
>>>>
>>>>> When reading code, I find it quite distracting to have to get past the
>>>>> import list to reach the actual module code, as the import list can be (and
>>>>> often is) quite big.
>>>>>
>>>>> So, why not issue import statements at the bottom of a module file?
>>>>>
>>>>> Likewise, we can use "where" statements to define names used in a
>>>>> function after using them, so they don't distract the reader.
>>>>>
>>>>> I'm against imports at the middle of the file.
>>>>> But I guess being able to issue them at the end of the module could
>>>>> make sense if you want to get the reader straight to the code.
>>>>>
>>>>> A language pragma could be used to select between top imports or
>>>>> bottom imports (can't use both).
>>>>>
>>>>> What do you think?
>>>>>
>>>>> Example:
>>>>>
>>>>> """
>>>>> {-# LANGUAGE LateImports #-}
>>>>> module Foo where
>>>>>
>>>>> bar :: String
>>>>> bar = "quux"
>>>>>
>>>>> baz :: Fiz
>>>>> baz = mkFiz
>>>>>
>>>>> import Fiz (Fiz, mkFiz)
>>>>> """
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Haskell-Cafe mailing list
>>>>> Haskell-Cafe at haskell.org
>>>>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>>>>>
>>>>>
>>>>
>>>
>>> _______________________________________________
>>> Haskell-Cafe mailing list
>>> Haskell-Cafe at haskell.org
>>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>>>
>>>
>>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>


-- 
Clark.

Key ID     : 0x78099922
Fingerprint: B292 493C 51AE F3AB D016  DD04 E5E3 C36F 5534 F907
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140422/f4f2e7c5/attachment.html>


More information about the Haskell-Cafe mailing list