<div dir="ltr">Roel, thanks, your solution works perfectly for me! I should've checked that implementation myself.<div><br></div><div>Richard, since Roel's solution works for me, I think I should not file this.</div><div><br></div><div>I think type-list [1] is the place on Hackage for list-related type-level functions.</div><div>I probably should send a PR adding Roel's Nub there.</div><div><br></div><div>Thanks for your help!</div><div>Nick</div><div><br></div><div>[1] <a href="https://hackage.haskell.org/package/type-list">https://hackage.haskell.org/package/type-list</a></div></div><br><div class="gmail_quote"><div dir="ltr">On Sun, 7 Feb 2016 at 18:24 Roel van Dijk <<a href="mailto:vandijk.roel@gmail.com">vandijk.roel@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Hi Nickolay,</div><div><br></div><div>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.</div><div><br></div><a href="https://gist.github.com/roelvandijk/f115c6b85a3961e1b689" target="_blank">https://gist.github.com/roelvandijk/f115c6b85a3961e1b689</a><div><br></div><div>Regards,</div><div>Roel</div></div><div dir="ltr"><div><br><div class="gmail_extra"><br><div class="gmail_quote">2016-02-07 14:37 GMT+01:00 Nickolay Kudasov <span dir="ltr"><<a href="mailto:nickolay.kudasov@gmail.com" target="_blank">nickolay.kudasov@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Dear Cafe,<div><br></div><div>I have faced a type-level performance problem (with GHC 7.10.3).</div><div>I am trying to implement type-level Nub which removes duplicates from a type-level list.</div><div><br></div><div>My implementation [1] 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).</div><div><br></div><div>My question is how can I speed up type-level Nub?</div><div>And less importantly why exactly is it this slow?</div><div><br></div><div>The practical application for this is building automatic tests [2] for servant-swagger. There I am interested in generating exactly one test for each distinct type.</div><div><br></div><div>Kind regards,</div><div>Nick</div><div><br></div><div>[1] <span><a href="https://gist.github.com/fizruk/06458fe8b62a1e562af1" target="_blank">https://gist.github.com/fizruk/06458fe8b62a1e562af1</a></span></div><div>[2] <a href="http://hackage.haskell.org/package/servant-swagger-1.0.2/docs/Servant-Swagger-Test.html" target="_blank">http://hackage.haskell.org/package/servant-swagger-1.0.2/docs/Servant-Swagger-Test.html</a></div></div>
</blockquote></div><br></div></div></div></blockquote></div>