Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First draft of a ChronicleT.CPS #174

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pkamenarsky
Copy link

This is a first draft of the ChronicleT CPS proposal in #173. However, there seems to be an inherent flaw in CPS-ifying ChronicleT akin to WriterT.CPS, in that chronicle needs to turn That into These in order to pass on the accumulated output. Also pure and return now generate a These value instead of That.

I'm open to any suggestions.

{-# INLINE chronicle #-}

runChronicle :: Monoid c => Chronicle c a -> These c a
runChronicle = runIdentity . flip runChronicleT mempty
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was afraid there is something like that, i.e. Monoid pops in, instead of Semigroup.

Just guessing, would ChronicleT { runChronicleT :: Maybe c -> m (These c a) } work better (and still do the job?)

t <- runChronicleT m c
case t of
This c' -> return (This c')
That a -> runChronicleT (k a) c
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this branch would have Nothing. It looks suspicious as is.

@phadej
Copy link
Collaborator

phadej commented Apr 9, 2022

don't worry about failures with older GHCs. I'll fix them up (or just drop support, pre-AMP GHCs are quite old).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants