runarorama/scala-machines

Need a non-Monoid (foldLeft style) driver implementation

jedws opened this issue · 2 comments

Specific use case is a non-associative operation across a file, such as computing a SHA1 hash

While it is possible to construct a hacked up Monoid to do this, associativity isn't really required, we really want foldLeft semantics.

I sketched something out: markhibberd@fe917e8

@jedws If you get bored, can you test out and see if that helps, if you can call executef.

@runarorama Does this actually make any sense? Is there a reason why the result has to be a monoid?

It does make sense. There's no reason it has to be a monoid per se. But change the name to *Left and it'll go in. Mind you, there is always a way to formulate a left fold as a mapping into a monoid (as evidenced by the fact that you can implementat foldLeft in terms of foldMap), but this is cleaner.