Open tel opened 9 years ago
Ignore the monadic bit, actually. I could never figure out the right place to put it anyway.
data FoldF a r b
= FoldF
{ reducer :: r -> a -> Either b r
, state :: Either b r
, output :: r -> b
}
-- | We forget the state variable to make it more composable
data Fold a b where Fold :: FoldF a r b -> Fold a b
type (-'a, +'b) spec =
{ step : 'a -> 's -> ('b, 's) sum
; state : ('b, 's) sum
; output : 's -> 'b
}
type (-_, +_) t = Ex : ('a, 'b, 's) state -> ('a, 'b) t
As seen here.