Skip to content

Instantly share code, notes, and snippets.

@isovector
Created July 17, 2016 08:17
Show Gist options
  • Select an option

  • Save isovector/48497057a45d8a68cdf220fb45798ce9 to your computer and use it in GitHub Desktop.

Select an option

Save isovector/48497057a45d8a68cdf220fb45798ce9 to your computer and use it in GitHub Desktop.
runStoryApp :: Comonad w => StoryApp a -> CoStoryAppT w b -> (a, b)
runStoryApp = pairEffect (,)
runStory :: Comonad w => Story a -> CoStoryT w b -> (a, b)
runStory = pairEffect (,)
mkCoStoryApp :: Comonad w
=> w b
-> (w b -> Character -> ChangeType -> w b)
-> (forall x y . (forall a. Story a -> b)
-> w b
-> StoryApp x
-> StoryApp y
-> w b)
-> (w b -> w b)
-> CoStoryAppT w b
mkCoStoryApp start changeH interruptH macguffinH =
fix $ flip coiterT start . next . flip runStoryApp
where
next run w =
CoStoryF
(changeH w)
(interruptH (unsafeCoerce run) w)
(macguffinH w)
mkCoStory :: Comonad w
=> w b
-> (w b -> Character -> ChangeType -> (ChangeResult, w b))
-> (forall x y . (forall a. Story a -> (a, b))
-> w b
-> Story x
-> Story y
-> (y, w b))
-> (w b -> (Desirable, w b))
-> CoStoryT w b
mkCoStory start changeH interruptH macguffinH =
fix $ flip coiterT start . next . flip runStory
where
next run w =
CoStoryF
(changeH w)
(interruptH (unsafeCoerce run) w)
(macguffinH w)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment