Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upsimplified sampleUpdate in Stream.sample #195
Conversation
jvoigtlaender
added some commits
Mar 11, 2015
jvoigtlaender
referenced this pull request
Mar 12, 2015
Merged
fixing Stream.sample in Elm-0.15 #193
evancz
reviewed
Mar 12, 2015
src/Stream.elm
| { state = b | ||
| , trigger = Just a | ||
| sampleUpdate : SampleEvent b a -> SampleState b a -> SampleState b a | ||
| sampleUpdate (ms,mu) state = |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
evancz
Mar 12, 2015
Member
Let's do better names than mu and ms. I don't know what they mean, and saving characters is not a good goal.
evancz
Mar 12, 2015
Member
Let's do better names than mu and ms. I don't know what they mean, and saving characters is not a good goal.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
evancz
reviewed
Mar 12, 2015
src/Stream.elm
| in | ||
| fold sampleUpdate { state = initialValue, trigger = Nothing } sampleEvents | ||
| |> fromVarying | ||
| |> filterMap (\state -> Maybe.map (f state.state) state.trigger) | ||
| type SampleEvent a b = Sample a | Update b | SampleAndUpdate a b | ||
| type alias SampleEvent b a = (Maybe b, Maybe a) |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
evancz
Mar 12, 2015
Member
What's the reason for switching the order here? Maybe we can give helpful names to these type variables instead?
evancz
Mar 12, 2015
Member
What's the reason for switching the order here? Maybe we can give helpful names to these type variables instead?
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
evancz
Mar 12, 2015
Member
I think this is far enough from convention to be pretty confusing. I'd either change the order of things such that it just matches (switching the args in genericMerge) or not bother with trying to get a and b to match.
evancz
Mar 12, 2015
Member
I think this is far enough from convention to be pretty confusing. I'd either change the order of things such that it just matches (switching the args in genericMerge) or not bother with trying to get a and b to match.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jvoigtlaender
added some commits
Mar 12, 2015
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jvoigtlaender
Mar 12, 2015
Contributor
How about now? The record type alias with named components makes it clearer?
|
How about now? The record type alias with named components makes it clearer? |
evancz
merged commit e42a973
into
elm:master
Mar 12, 2015
1 check failed
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
evancz
Mar 12, 2015
Member
I did some last bits of cleanup, but I this is overall a lot nicer, thank you!
|
I did some last bits of cleanup, but I this is overall a lot nicer, thank you! |
jvoigtlaender commentedMar 12, 2015
... and renamed some type variables so that
aandbinSampleEventandSampleStatecorrespond to the roles ofaandbin the type ofsample.