[Haskell-cafe] determining the origin of imported symbols
Erik Rantapaa
erantapaa at gmail.com
Thu Jul 24 17:56:14 UTC 2014
Thanks, everyone, for all of the suggestions!
On Thursday, July 24, 2014 5:53:59 AM UTC-5, Eyal Lotem wrote:
>
> There's also ghc's -ddump-minimal-imports which might help you.
>
>
> On Thu, Jul 24, 2014 at 12:06 PM, JP Moresmau <jpmor... at gmail.com
> <javascript:>> wrote:
>
>> BuildWrapper doesn't do the transformation, but it resolves all symbols
>> to build a usage map, so it would tell you that Data.List.sort is used at
>> line xxx, using the GHC API. So have a look at around
>> https://github.com/JPMoresmau/BuildWrapper/blob/master/src/Language/Haskell/BuildWrapper/API.hs#L239.
>> BuildWrapper takes the GHC AST, transforms it into a JSON structure, and
>> extracts all usage information. There is also an import reorganization
>> function that may be useful.
>>
>> JP
>>
>>
>> On Thu, Jul 24, 2014 at 10:29 AM, Erik Rantapaa <eran... at gmail.com
>> <javascript:>> wrote:
>>
>>> Hi everyone,
>>>
>>> I looking for a way to analyze Haskell source to determine which module
>>> each imported symbol comes from. My goal is to transform source code like
>>> this:
>>>
>>> import Data.List
>>> ...
>>> main = do
>>> nums <- fmap (map read . words) getLine :: IO [Int]
>>> print $ sort nums
>>>
>>> to code like this:
>>>
>>> import qualified Prelude as B
>>> import qualified Data.List as A
>>> ...
>>> main = do
>>> nums <- B.fmap (B.map B.read B.. B.words) B.getLine :: B.IO
>>> [B.Int]
>>> B.print B.$ A.sort nums
>>>
>>> That is, I want to qualify all imported symbols with a module alias.
>>>
>>> Can anyone suggest modules or programs I should look at?
>>>
>>> Thanks,
>>> ER
>>>
>>> _______________________________________________
>>> Haskell-Cafe mailing list
>>> Haskel... at haskell.org <javascript:>
>>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>>>
>>>
>>
>>
>> --
>> JP Moresmau
>> http://jpmoresmau.blogspot.com/
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Haskell-cafe" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to haskell-cafe... at googlegroups.com <javascript:>.
>> To post to this group, send email to haskel... at googlegroups.com
>> <javascript:>.
>> Visit this group at http://groups.google.com/group/haskell-cafe.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> Eyal
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140724/30c5b4d5/attachment.html>
More information about the Haskell-Cafe
mailing list