-
Notifications
You must be signed in to change notification settings - Fork 23
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
Fix dot documentation #32
base: master
Are you sure you want to change the base?
Conversation
I goofed up and made the ``strat1 `dot` strat1 = strat1`` law too strong. Fix that. Also, add laws for ``rpar `dot` rseq`` and ``rseq `dot` rpar``.
-- | ||
-- > strat `dot` r0 == strat | ||
-- > strat `dot` rseq == strat | ||
-- > strat `dot` rpar == strat |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that true?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe so, yes. runEval m
is a lifted value; it doesn't do anything until it's forced. Forcing runEval (r0 x)
runs the usual return x
IO
computation, so that gives you x
. Forcing runEval (rseq x)
runs an IO
computation that forces x
to WHNF and returns the result (exactly the same as forcing x
directly). Forcing runEval (rpar x)
runs an IO
computation that sparks a thread to evaluate x
to WHNF, but immediately forces the result so the thread (almost certainly) fizzles.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r0 `dot` rseq == r0
r0 `dot` rpar == r0
Would be counterintuitive to my expectations, of the first description of dot
, namely: "Compose two strategies sequentially". Or more explicitely:
"Composing the 'do nothing'-strategy with the 'evaluate to WHNF'-strategy sequentially, creates the 'do nothing'-strategy"
Am I the only, who thinks this sounds weird?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r0 `dot` rseq
is not r0
. But rseq `dot` r0 = rseq
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Last comment corrected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dot
is a composition operator in a semigroupoids
sense: namely, it is associative. But it doesn't form a category, which makes intuition around it a little tricky. @Borgvall, by definition,
f `dot` g = \x -> f (runEval (g x))
Think about what runEval (r0 x)
, runEval (rpar x)
, and runEval (rseq x)
do when forced. Ultimately the same thing (if you ignore sparks that fizzle). If you don't force them, they all do ... nothing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I care about sparking, this is the main reason to use this library!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still concerned about strat
dot rpar == strat
We can construct contrived examples in which this doesn't apply, at least operationally (and operationally is after all the point of the library, so the equalities should be operational ones). e.g.
let strat n x = rseq (fib n) >> return x in strat 99999 `dot` rpar
If strat
is very slow then the spark doesn't fizzle immediately and we get some useful parallelism. Of course it's hard to reliably define a strategy that's very slow (the example above could easily be optimised), but the fact that it's possible at all implies that we can't assume the spark fizzles immediately.
You are contradicting yourself.
In the commit line 308 you say:
"strat `dot` rseq == strat" for all strat, but if strat = r0 it is not.
--
Diese Nachricht wurde von meinem Android Mobiltelefon mit GMX Mail gesendet.Am 09.06.18, 18:16, David Feuer <[email protected]> schrieb:
@treeowl commented on this pull request.
In Control/Parallel/Strategies.hs:
--
--- > strat2 `dot` strat1 == strat2 . withStrategy strat1
+-- 'r0', 'rseq', and 'rpar' are all one-sided identities of 'dot':
+--
+-- > strat `dot` r0 == strat
+-- > strat `dot` rseq == strat
+-- > strat `dot` rpar == strat
r0 `dot` rseq is not r0. But rseq `dot` r0 = r0.
—You are receiving this because you commented.Reply to this email directly, view it on GitHub, or mute the thread.
{"@context":"http://schema.org","@type":"EmailMessage","potentialAction":{"@type":"ViewAction","target":"https://github.com/haskell/parallel/pull/32#discussion_r194232298","url":"https://github.com/haskell/parallel/pull/32#discussion_r194232298","name":"View Pull Request"},"description":"View this Pull Request on GitHub","publisher":{"@type":"Organization","name":"GitHub","url":"https://github.com"}}
{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/haskell/parallel","title":"haskell/parallel","subtitle":"GitHub repository","main_image_url":"https://assets-cdn.github.com/images/email/message_cards/header.png","avatar_image_url":"https://assets-cdn.github.com/images/email/message_cards/avatar.png","action":{"name":"Open in GitHub","url":"https://github.com/haskell/parallel"}},"updates":{"snippets":[{"icon":"PERSON","message":"@treeowl commented on #32"}],"action":{"name":"View Pull Request","url":"#32 (comment)"}}}
{
"@type": "MessageCard",
"@context": "http://schema.org/extensions",
"hideOriginalBody": "false",
"originator": "AF6C5A86-E920-430C-9C59-A73278B5EFEB",
"title": "@treeowl commented on 32",
"sections": [
{
"text": "",
"activityTitle": "**David Feuer**",
"activityImage": "https://assets-cdn.github.com/images/email/message_cards/avatar.png",
"activitySubtitle": "@treeowl",
"facts": [
]
}
],
"potentialAction": [
{
"targets": [
{
"os": "default",
"uri": "#32 (comment)"
}
],
"@type": "OpenUri",
"name": "View on GitHub"
},
{
"name": "Unsubscribe",
"@type": "HttpPOST",
"target": "https://api.github.com",
"body": "{\n\"commandName\": \"MuteNotification\",\n\"threadId\": 342129584\n}"
}
],
"themeColor": "26292E"
}
|
I mistyped that comment. It's corrected on the web.
…On Sat, Jun 9, 2018, 3:50 PM Johannes Röhl ***@***.***> wrote:
You are contradicting yourself.
In the commit line 308 you say:
"strat `dot` rseq == strat" for all strat, but if strat = r0 it is not.
--
Diese Nachricht wurde von meinem Android Mobiltelefon mit GMX Mail
gesendet.Am 09.06.18, 18:16, David Feuer ***@***.***>
schrieb:
@treeowl commented on this pull request.
In Control/Parallel/Strategies.hs:
> --
--- > strat2 `dot` strat1 == strat2 . withStrategy strat1
+-- 'r0', 'rseq', and 'rpar' are all one-sided identities of 'dot':
+--
+-- > strat `dot` r0 == strat
+-- > strat `dot` rseq == strat
+-- > strat `dot` rpar == strat
r0 `dot` rseq is not r0. But rseq `dot` r0 = r0.
—You are receiving this because you commented.Reply to this email
directly, view it on GitHub, or mute the thread.
***@***.***":"http://schema.org
***@***.******@***.***":"ViewAction","target":"
#32 (comment)","url":"
#32 (comment)","name":"View
Pull Request"},"description":"View this Pull Request on
***@***.***":"Organization","name":"GitHub","url":"
https://github.com"}}
{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/haskell/parallel","title":"haskell/parallel","subtitle":"GitHub
repository","main_image_url":"
https://assets-cdn.github.com/images/email/message_cards/header.png
","avatar_image_url":"
https://assets-cdn.github.com/images/email/message_cards/avatar.png","action":{"name":"Open
in ***@***.***
commented on #32"}],"action":{"name":"View Pull Request","url":"
#32 (comment)"}}}
{
***@***.***": "MessageCard",
***@***.***": "http://schema.org/extensions",
"hideOriginalBody": "false",
"originator": "AF6C5A86-E920-430C-9C59-A73278B5EFEB",
"title": ***@***.*** commented on 32",
"sections": [
{
"text": "",
"activityTitle": "**David Feuer**",
"activityImage": "
https://assets-cdn.github.com/images/email/message_cards/avatar.png",
"activitySubtitle": ***@***.***",
"facts": [
]
}
],
"potentialAction": [
{
"targets": [
{
"os": "default",
"uri": "#32 (comment)"
}
],
***@***.***": "OpenUri",
"name": "View on GitHub"
},
{
"name": "Unsubscribe",
***@***.***": "HttpPOST",
"target": "https://api.github.com",
"body": "{\n\"commandName\": \"MuteNotification\",\n\"threadId\":
342129584\n}"
}
],
"themeColor": "26292E"
}
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#32 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABzi_QAA8CwmZzijHI6DlZ91wjF05WO_ks5t7CcGgaJpZM4UZHuw>
.
|
In the edited version of your comment you sai: "r0 -- strat `dot` rseq == strat [for all strat even r0] So you are still contradicting yourself. |
Yes, I did make a mistake. |
@treeowl can I let you merge it? |
I don't understand the question. I don't have permission to merge things to master. |
As this old merge request has been resurrected, I revisited it. My current point of view is, that the documentation is as weird as the implementation of IMHO the |
I agree that We should definitely fix the documentation (although there's still an unresolved review), but I'm sympathetic to deprecating |
I goofed up and made the
strat1 `dot` strat1 = strat1
law toostrong. Fix that. Also, add laws for
strat `dot` rseq
andstrat `dot` rpar
.