-
Notifications
You must be signed in to change notification settings - Fork 43
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
Improve documentation for ListT instances #117
Comments
For some background, look around for "ListT done right". http://h2.jaguarpaw.co.uk/posts/listt-done-wrong/ In particular |
Hi. Thanks for the references. I'm checking out your first link now, and actually, your second link is how I found my way to Volkov's implementation. The discussion online about how and when |
Wow, Tom Ellis's explanation of the ListT-monad issue is good. It gets to the point, and it makes the crux of the problem immediately apparent. Really, thanks for the link. |
I was experimenting with some code when I noticed what seemed to me an interesting discrepancy between List and ListT, but opening an issue about this difference was probably overly enthusiastic. PureScript's core team of maintainers is doing a phenomenal job, but they have a lot on their plates. I don't want to overwhelm them with minor stuff like this, so I think I'll just close this issue. Thanks, though, for any looks this issue has already gotten. |
I wouldn't say overly enthusiastic - the documentation here can definitely be improved, so I think this is worth keeping open. |
Apply
implementations of List
and ListT
match?
Oh, ok. I'm glad this issue has some value then after all. Thanks for reopening it. |
What kind of effect-sequencing behavior is
ListT
supposed to exhibit? I ask because in haskell,ListT m a
is a newtype wrapper ofm [a]
, and if purescript'sListT
is meant to be modeled after haskell's,ListT Effect Int
should perhaps then behave likeEffect [Int]
. However, the haskell community has also considered alternative models forListT
like the following:Because
ListT
in Pursuit's 'transformers' package is defined as ...... Volkov's
ListT
(shown above) seems to be the underlying model for purescript's ownListT
.What kind of effect-sequencing behavior, then, should Volkov's
ListT
exhibit? Unfortunately, at the moment, I can't experiment with his code directly; however, it seems that, under specific conditions, Volkov'sListT m Int
should behave similarly to[m Int]
-- in particular, when a list-like construct in either case (ListT m Int
or[m Int]
) is fully traversed/consumed with pre-order congruence and the final effect ofListT
is pure or ignored. (Or at least I assume; perhaps there are details that invalidate this comparison.)If this comparison is sound, users in purescript-land might expect values of the analogous purescript types
ListT Effect Int
,List (Effect Int)
andCompose List Effect Int
, under appropriate conditions, also to exhibit identical behavior. I'm not sure that's the case, however.Consider, for example,
product0
andproduct1
below:If
product0
andproduct1
are fully traversed, results like the following occur:Other helpful comparisons to try might include the following:
Although I've tried to model the same sequence of bundled data and effects as both an instance of
ListT Effect Int
and as an instance ofCompose List Effect Int
and although I (myself at least) expect similar behavior because of my assumptions listed above, the two valuesproduct0
andproduct1
have different overall effects when traversed.The source of this difference in behavior appears to be related to the
Apply
typeclass. WhereasList
'sapply
member has a static flavor,ListT
's implementation ofapply
is monadic and therefore directionally biased.I'm not sure which style of applicative multiplication might be generally preferable. I'm not even sure that
List
andListT
should have exactly identical effect-sequencing semantics (in relevant scenarios). However, because this difference in behavior surprised me at least, I figured I'd note this distinction as an issue for maintainers to consider. Perhaps it's a point confusing/interesting enough to include in documentation.Thanks much
The text was updated successfully, but these errors were encountered: