Closed coot closed 4 years ago
I agree, it might be nice to try to improve the performance here a bit. We could add a builder api to arrays
, or maybe it could just be as simple as specializing this for some small values of n.
Or maybe using your approach with ST
monad. I added Array String
instance which does the same as the RowLabels
class in this PR. Check out this gist.
Maybe the way forward is to have a RowLabels
(optimised by speciallising up to 10 arguments) and the ST
builder published somewhere (in Control.Module.ST.Builder
in purescript-st
or in a new package).
RowLabels
at some point can be optimized by the compiler, since all the information is static, then there is no need for the ST
builder.
Yes, let's try that.
If you want the ST stuff in purescript-contrib you'll need to create a repo for that. I can maintain it.
I added test (in the prelude style in Unit -> Unit
monad). Seems there is an issue with the development version of the compiler (the only one I tried). It takes too much time to compile the test file:
time purs compile ...
Compiling Test.Main
purs compile 'bower_components/purescript-*/src/**/*.purs' 'src/**/*.purs' 41.16s user 13.72s system 368% cpu 14.880 total
time pulp test
* Building project in /home/marcin/repos/purescript/purescript-typelevel-prelude
Src Lib All
Warnings 0 0 0
Errors 0 0 0
* Build successful.
* Running tests...
* Tests OK.
pulp test 43.16s user 11.92s system 360% cpu 15.283 total
@coot Thanks!
@LiamGoodacre What do you think of the unrolled loop idea?
I'm okay-ish with the unrolling - at least, in the absence of compiler optimisations. However, I'm wondering if we should build a List
instead of an Array
? If the issue is specifically that arrays have poor cons perf.
I think that would be fine too, but I'm also a little concerned that we'll have one dictionary lookup and function call per label.
Promissed PR as discussed in https://github.com/purescript/purescript-record/pull/6 I think we could use
pushd
via ffi instead ofcons x xs = [x] <> xs
hack.