-
Notifications
You must be signed in to change notification settings - Fork 24
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
new function existsAnd : (a -> Bool) -> Maybe a -> Bool
#56
Comments
I've tried various streaming's versions of the functions to make https://github.com/NeilW/elm-orderbook/blob/master/src/OrderBook.elm#L192 clearer, but nothing is as clear as writing it out. And even that's not that clear :-) I actually want which would perhaps allow a curry
|
That
That would suggest using buyIsFillable : OrderRequest -> ( Order, Heap Order ) -> Bool
buyIsFillable activeBuy ( passiveSell, _newSell ) =
Maybe.Extra.all (\buyPrice -> buyPrice >= passiveSell.price) activeBuy.price
...
config.getpassiveQueue book
|> Heap.pop
|> Maybe.Extra.filter (config.isFillable activeRequest) But I see the need for
|
With the last two fitting nicely with the existing |
Maybe
is basically aList
with 0 or 1 elements. All the functions inList
and Haskell'sFoldable
class have equivalents inMaybe
orMaybe.Extra
, or don't make sense with only 1 element, except forfold
(which is handled by #55) andany
/all
.The difference between
any
andall
forMaybe
would be in the empty case.I think this is a pretty simple thing to want to do that
Maybe
andMaybe.Extra
don't support right now. There isn't really a good way to run a predicate on a Maybe. You could dofilter predicate >> isJust
ormap predicate >> withDefault False
, but those don't really express the idea of "do I have something that matches" well.I found several examples of people implementing
any
with a variety of names:exists
extractBool
existsAnd
(??)
maybePredicate
maybePredicate
I saw no examples of people implementing
all
.I propose adding a single new function for
any
, but with a different name that's less list-like and more maybe-like. MaybeexistsAnd
orisJustAnd
. I think those names would look good in a pipeline.Thoughts?
The text was updated successfully, but these errors were encountered: