[Haskell-cafe] how to generate source code from TH Exp?

Daniel Fischer daniel.is.fischer at googlemail.com
Thu May 12 19:31:44 CEST 2011


On Thursday 12 May 2011 19:14:09, Felipe Almeida Lessa wrote:
> On Thu, May 12, 2011 at 2:04 PM, Stefan Kersten <sk at k-hornz.de> wrote:
> > extractModules = sort . nub . everything (++) ([] `mkQ` f)
> >     where f (NameQ x) = [modString x]
> >           f (NameG _ _ x) = [modString x]
> >           f _ = []
> 
> Minor nitpick:  instead of doing 'sort . nub', please use 'import
> qualified Data.Set as S' and do 'S.toAscList . S.fromList'.  This
> should be a lot faster.

Or `map head . group . sort', which may be faster than building an 
intermediate Set (haven't benchmarked, may be faster, slower or mkae no 
difference).

> 
> Cheers, =)



More information about the Haskell-Cafe mailing list