-
Notifications
You must be signed in to change notification settings - Fork 69
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
Revise documentation and tests for induceJust #211
Conversation
@nobrakal @Avasil Note that we now have these properties in docs/tests: induceJust . fmap (\x -> if p x then Just x else Nothing) == induce p
induceJust1 . fmap (\x -> if p x then Just x else Nothing) == induce1 p It would be nice to check if we could use this in the implementations of |
@snowleopard I have a question about benchmarking though. Do you have any example how to do it properly? I know about https://github.com/haskell-perf/graphs but it looks like it loads a dependency so I can't easily check different functions' implementations |
@snowleopard I fixed (again) the bench suite, it should run. Anyway, I am not really proud of the code behind it as I tried to reinvent the wheel while I should have used more primitive from @Avasil The help message should be informative. Just if you want to mess with it, it actually makes a copy of alga's master branch, changes its name to "old", adds it as a library in |
@nobrakal Many thanks for the fix! :-) |
@nobrakal Actually, something is wrong. Could you look at this failure? https://travis-ci.org/snowleopard/alga/jobs/557899321. |
Ah, I forgot to mention that the suite needs many dependencies, and because I updated them, Cabal re-downloaded them all. @snowleopard Just restart the build, the cache should've been updated now. |
@nobrakal Indeed, green now, thanks! |
@nobrakal Thanks for the script, I will try it soon! If you don't mind, I have a question about rewrite rules. I'm also adding rewrite rule to "buildR/induceJust" [~1] forall g.
induceJust g = buildR (\e v o c -> foldg e (maybe e v) o c g) I followed "buildR/induce" [~1] forall p g.
induce p g = buildR (\e v o c -> foldg e (matchR e v p) o c g) Though I had to use |
I realized I did not explain what was going on here. Let me sum up: When expressed with
The only problem is that we want to recognize the form of the right part of the equality of For your case, I think you should define something like: maybeR :: b -> (a -> b) -> Maybe a -> b
maybeR e f x = maybe e f x
{-# INLINE [0] maybeR #-} and follow the same process. |
See #202 and #209.