Closed infinity0 closed 3 years ago
I just ran cabal bench
and there's no noticeable difference with or without this patch - some results are a little bit slower, some are a little bit quicker.
The main reason that I'm reluctant to merge this is that the proofs in laws.md
(Link) are written in terms of the old implementation and I've have to update them all accordingly. Also, the fact that fix{l,r,m}
are partial functions makes me uneasy, too.
Understood, I'll see if I can apply this factoring to the laws when I next get some time.
fix{l,r,m}
each would only be partial functions if go
directly calls into it at any of the points that it directly calls into go
. It should be easy for a given piece of code to avoid this though - probably easier than trying to prove laws about it, at any rate. (Ideally we'd have one unconditionally total function fix
, but it's unclear that I can get Haskell to type-check this in the way that's needed.)
This makes the code easier to understand, since one can now more quickly ignore the boilerplate without inspecting it "in case" it might be different. It also makes the instance functions less dependent on some internal details of Proxy.
I marked all of the functions as INLINABLE so there should be no runtime cost. (INLINE may be better, but I'm not familiar with Haskell internals to be able to judge this by myself.)
Ideally we would write fixm,fixl,fixr as one function, but I couldn't figure out how to satisfy the type checker in this way.