-
Notifications
You must be signed in to change notification settings - Fork 39
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
Implement Fuzz.filterMap #220
Conversation
Hey there! Thanks for the contribution. Can you please provide more info about your usecase? Just so that I can get my head around when this code would be useful. Re tests, you can try The code itself looks good, I'd just
fuzzer |> filterMap f |> map ((/=) Nothing)
===
fuzzer |> filter (f >> (/=) Nothing) |
Examples of cases when you want module UnicodeNonLetter exposing (UnicodeNonLetter, fromChar, fuzz)
type UnicodeNonLetter = UnicodeNonLetter Char
fromChar : Char -> Maybe UnicodeNonLetter
fromChar c =
if (c |> Unicode.isLower |> not) && (c |> Unicode.isUpper |> not) then
UnicodeNonLetter |> Just
else
Nothing
fuzz : Fuzzer UnicodeNonLetter
fuzz =
Fuzz.char |> Fuzz.filterMap fromChar |
Sounds lovely - that would be a nice example to have in the docs 👍 |
Hi @Janiczek , sorry for the delay but thanks for your review.
Is it ok if I borrow the example from @lue-bird ?
Could you provide me some guidance about that? |
Sure thing!
Actually, ignore this requirement. I wasn't fully switched into the "Fuzzers are functions" train of thought when writing that... I was thinking in Lists. I don't think we have an easy way to test equivalence of fuzzers right now. There might be some in the future but let's skip this for now. |
6545e6d
to
82d06f8
Compare
82d06f8
to
55c4cd2
Compare
Hi @Janiczek , I finally found some time to update my PR, it should be good now. Let me know if there are still things to fix. |
Hey @mbaechler, the CI tests failed because of a forgotten stale version in tests/elm.json. I've fixed it here: 81b15e2 I'm gonna pull master into your branch and try the tests again. |
Thanks for your work on this! |
I needed this function on a project I'm working on so I figured it could be interesting to contribute it back upstream.
edit: By the way, I couldn't run the test locally, I expect to CI to help me about that.