[Haskell-cafe] Incredibly slow type-level Nub
nickolay.kudasov at gmail.com
Sun Feb 7 20:27:19 UTC 2016
Roel, thanks, your solution works perfectly for me! I should've checked
that implementation myself.
Richard, since Roel's solution works for me, I think I should not file this.
I think type-list  is the place on Hackage for list-related type-level
I probably should send a PR adding Roel's Nub there.
Thanks for your help!
On Sun, 7 Feb 2016 at 18:24 Roel van Dijk <vandijk.roel at gmail.com> wrote:
> Hi Nickolay,
> I'm not sure why your version was *that* slow. But the algorithm was not
> optimal. I translated the Haskell Report prelude version of nub to the type
> level. That version compiles instantly with the long list. I tested with
> GHC 7.10.2.
> 2016-02-07 14:37 GMT+01:00 Nickolay Kudasov <nickolay.kudasov at gmail.com>:
>> Dear Cafe,
>> I have faced a type-level performance problem (with GHC 7.10.3).
>> I am trying to implement type-level Nub which removes duplicates from a
>> type-level list.
>> My implementation  with an example of a list of length 20 takes
>> forever to compile. If you reduce the size of the example list (e.g. to 15
>> items), it will compile faster. Also, if you remove the Nub application
>> from exampleVals, it compiles instantly (this is how I know the problem is
>> in Nub).
>> My question is how can I speed up type-level Nub?
>> And less importantly why exactly is it this slow?
>> The practical application for this is building automatic tests  for
>> servant-swagger. There I am interested in generating exactly one test for
>> each distinct type.
>> Kind regards,
>>  https://gist.github.com/fizruk/06458fe8b62a1e562af1
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe