Skip to content

Instantly share code, notes, and snippets.

@mbloms
Created December 15, 2017 00:50
Show Gist options
  • Save mbloms/c9a1aabbe5b0568b0b4df7a90a778749 to your computer and use it in GitHub Desktop.
Save mbloms/c9a1aabbe5b0568b0b4df7a90a778749 to your computer and use it in GitHub Desktop.
Comonadic fixed point
-- Normal fixed point
fix f = f (fix f)
-- | Slow comonadic fixed point à la Kenneth Foner:
pfix :: Comonad w => w (w a -> a) -> w a
pfix = extend wfix
-- | Comonadic fixed point à la Kenneth Foner:
kfix :: ComonadApply w => w (w a -> a) -> w a
kfix w = fix $ \u -> w <@> duplicate u
-- | Comonadic fixed point à la Blom:
bfix :: ComonadApply w => w (w a -> a) -> w a
bfix w = w <@> extend bfix w
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment