Skip to content

Conversation

@kaol
Copy link
Contributor

@kaol kaol commented Jan 14, 2020

I would like to propose these two new functions for Heist.Compiled.

deferManyElse is useful for showing "no results" or some such message when passed an empty Foldable. I was considering maybeDefer as the name since it's analogous to maybe but maybe is useful for just Maybe and not for Foldable in generic.

deferEither is much like either but for splices. At least my code's full of splices that do DB operations and I need to do something with all the runtime Lefts.

I'm not proposing adding any deferManyElseMap or deferEitherMap, since deferEitherMap f a b n can be written as just deferEither a b $ f =<< n. Same goes for deferManyElseMap.

If it was up to me, I would deprecate both deferMap and mayDeferMap, since they can be substituted with defer and deferMany, respectively.

@kaol kaol force-pushed the eitherDefer+deferManyElse branch from e364dea to 5a32eed Compare January 14, 2020 21:36
@mightybyte
Copy link
Member

This looks good, but it's not building on older GHCs (see https://travis-ci.org/github/snapframework/heist/builds/637120129). Any chance we could preserve that compatibility?

@kaol
Copy link
Contributor Author

kaol commented Jun 24, 2020

Easy, it just needs to use foldr (\_ _ -> False) True in there, which is the current definition of null. Old versions use pattern matching and the type is restricted to [a] -> Bool. Just a moment and I'll refresh this branch.

@kaol kaol force-pushed the eitherDefer+deferManyElse branch from 5a32eed to f58893b Compare June 24, 2020 13:29
@mightybyte
Copy link
Member

Hmmm, it doesn't look like CI was triggered. Perhaps that's because it was a force push?

@mightybyte
Copy link
Member

I created another local branch and that doesn't seem to have fixed it. https://travis-ci.org/github/snapframework/heist/builds/701697177

@kaol kaol force-pushed the eitherDefer+deferManyElse branch from f58893b to d5edfa3 Compare June 26, 2020 07:55
@kaol
Copy link
Contributor Author

kaol commented Jun 26, 2020

I amended and force pushed another version of this. Copying null from new base wasn't enough but it needed a new foldr as well. I tested the definition at home with 7.8.4 and 8.4.4.

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