module Fold.Shortcut.Utilities where
import Fold.Shortcut.Type
import Strict (willSave)
import qualified Strict
demotivate :: ShortcutFold a b -> ShortcutFold a b
demotivate :: forall a b. ShortcutFold a b -> ShortcutFold a b
demotivate 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 } =
ShortcutFold
{ initial :: Vitality (Either x y) y
initial = forall a b. Vitality a b -> Vitality (Either a b) b
willSave Vitality x y
initial
, step :: y -> a -> Vitality (Either x y) y
step = \y
x a
a -> forall a b. Vitality a b -> Vitality (Either a b) b
willSave (y -> a -> Vitality x y
step y
x a
a)
, extractDead :: Either x y -> b
extractDead = \Either x y
e -> case Either x y
e of
Strict.Left x
x -> x -> b
extractDead x
x
Strict.Right y
x -> y -> b
extractLive y
x
, extractLive :: y -> b
extractLive = y -> b
extractLive
}