Open jacereda opened 3 years ago
Of course we could implement manually traverse
on our AST, but I thought an automatic instance based on Generic
would be more desirable.
This sounds interesting indeed! What would be a good module to first try out this approach?
You mean if it should be Eval
or Expand
? I guess the second is simpler...
Oh, instead of Generic
we could also use https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts.html#extension-DeriveTraversable
Oh, maybe those are the only ones... :)
guess the second is simpler
Yes it must be
I guess Scoring
is a fold. Not sure about Emit
, could it also be a fold?
And looking at more modules, looks like most of them could benefit from Foldable
and/or Traversable
.
I guess
Scoring
is a fold. Not sure aboutEmit
, could it also be a fold?And looking at more modules, looks like most of them could benefit from
Foldable
and/orTraversable
.
Yes, pretty much everything, I think, can be expressed in terms of a fold over the AST
Some of the recursive functions branch in weird ways though - concretize & manageMemory comes to mind. Perhaps it's still possible to just fold, but I'm not sure.
I thought I might raise this issue to discuss the possibility of evaluating via
Traversable
.One of the stumbling blocks I found is the
Set
s we have in the AST. NormalData.Set
isn'tTraversable
because it hasOrd
restrictions.I found https://github.com/giorgidze/set-monad but it doesn't have
Traversable
. I have PR'd https://github.com/giorgidze/set-monad/pull/10Maybe there're other alternatives. I guess we could implement a simplified
Set
withoutOrd
restriction. Since our sets will be quite small I guess something like that could be implemented on top ofList
without being too inefficient.