ssadler / hawk

Awk for Hoodlums
BSD 3-Clause "New" or "Revised" License
35 stars 2 forks source link

Support fancy import statements #42

Open gelisam opened 11 years ago

gelisam commented 11 years ago

Such as

import Prelude hiding (lines, unlines)

for example.

gelisam commented 11 years ago

While reading the documentation for hint, I stumbled upon a function which lists all the bindings exported by a module. If we need any hacks in order to support fancy import statements, that function will probably be help to implement them.

melrief commented 11 years ago

I have an idea: for selective and hiding imports we can just populate the user prelude.hs with exports. So a Prelude.hs like:

import Data.List (length)

will be converted to

module Hawk.M12345678 (length) where
import Data.List (length)

same for hiding, we can take everything exported by the module and remove what has been hidden. I think hint has something to get what is exported by a module. This will require a bit of work, but it can be done and it is invisible to the user

gelisam commented 11 years ago

This is exactly the kind of magic I like :)