Fusion: actually implement list rewrite rule
Dependencies
- [2]
6XMVEBZAadd simple stuff (e.g. haskell basics)
Change contents
- edit in core/lib/GardGround/Utils/Fusion.hs at line 7
runSteps, - replacement in core/lib/GardGround/Utils/Fusion.hs at line 9
runStream,stream,unstream, - replacement in core/lib/GardGround/Utils/Fusion.hs at line 72
runSteps :: StepFun s a -> s -> [a]runSteps (StepFun sf) = godata Stream a = forall s. Stream(StepFun s a) -- ^ stepper function!s -- ^ current stateinstance Functor Stream wherefmap f (Stream step_ cst) = Stream (fmap f step_) cstunstream :: Stream a -> [a]unstream (Stream (StepFun sf) ctx) = go ctx - edit in core/lib/GardGround/Utils/Fusion.hs at line 86
{-# INLINE [0] unstream #-} - replacement in core/lib/GardGround/Utils/Fusion.hs at line 88
data Stream a = forall s. Stream(StepFun s a) -- ^ stepper function!s -- ^ current state-- | convert a list to a streamstream :: [a] -> Stream astream = Stream (StepFun go)wherego [] = Donego (x:xs) = Yield x xs{-# INLINE [0] stream #-} - replacement in core/lib/GardGround/Utils/Fusion.hs at line 96
instance Functor Stream wherefmap f (Stream step_ cst) = Stream (fmap f step_) cstrunStream :: Stream a -> [a]runStream (Stream sf ctx) = runSteps sf ctx{-# INLINE runStream #-}{-# RULES"gardground stream/unstream" forall (s :: Stream a). stream (unstream s) = s#-}