Skip to content

Instantly share code, notes, and snippets.

@mbloms
Last active December 16, 2017 13:45
Show Gist options
  • Save mbloms/a03e20c8f2d90d48c93a9ffee944871b to your computer and use it in GitHub Desktop.
Save mbloms/a03e20c8f2d90d48c93a9ffee944871b to your computer and use it in GitHub Desktop.
ComonadScan
class Comonad w => ComonadScan w where
scanW :: (a -> w b -> a) -> a -> w b -> w a
scanW f acc w = (duplicate w)
instance ComonadScan Tree where
scanW f acc w@(Node _ as) = let acc' = f acc w in Node acc' (map (scanW f acc') as)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment