module Fold.Shortcut.Run where
import Fold.Shortcut.Type
run :: ShortcutFold a b -> [a] -> b
run :: forall a b. ShortcutFold a b -> [a] -> b
run ShortcutFold{ Vitality x y
initial :: ()
initial :: Vitality x y
initial, y -> a -> Vitality x y
step :: ()
step :: y -> a -> Vitality x y
step, x -> b
extractDead :: ()
extractDead :: x -> b
extractDead, y -> b
extractLive :: ()
extractLive :: y -> b
extractLive } = Vitality x y -> [a] -> b
go Vitality x y
initial
where
go :: Vitality x y -> [a] -> b
go (Alive Will
Tenacious y
x) (a
a : [a]
as) = Vitality x y -> [a] -> b
go (y -> a -> Vitality x y
step y
x a
a) [a]
as
go (Alive Will
Tenacious y
x) [] = y -> b
extractLive y
x
go (Alive Will
Ambivalent y
x) [a]
_ = y -> b
extractLive y
x
go (Dead x
x) [a]
_ = x -> b
extractDead x
x