[Haskell-cafe] Proposal: Shorter Import Syntax
Richard A. O'Keefe
ok at cs.otago.ac.nz
Fri Jun 5 04:23:27 UTC 2015
On 4/06/2015, at 5:15 am, Anthony Cowley <acowley at seas.upenn.edu> wrote:
> The idea is that rather than writing,
> import Data.Map (Map)
> import qualified Data.Map as M
> you could instead write,
> import Data.Map (Map) as M
This puts the list (Map) in the wrong place.
You know how in English, "heavy" parts of a sentence go at the end?
The "heavy" part of an import declaration is the impspec.
> The Map identifier would imported unqualified, while M would be
> introduced as an alias for the qualified import of Data.Map.
I find that confusing. I expected it to mean that
only Data.Map.Map would be available and that it would
have to be referred to as M.Map. The core problem is
that this is a bit too close to English syntax, where
the placement of "as M" after (Map) suggests that it
refers to (Map), rather than to Data.Map.
The new syntax does not let us do anything we cannot do now.
It is also asking too much to ask people to distinguish
import Full as Local (thingy) -- current
import Full (thingy) as Local -- proposed
Whatever its faults, the current scheme at least makes
it obvious that 'as Local' refers to 'Full', not '(thingy)'.
More information about the Haskell-Cafe