-
Notifications
You must be signed in to change notification settings - Fork 40
Dupable wars : implementation #360
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
Conversation
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.
What I would like to see, as well, is a function in Data.Array.Mutable.Linear
which defines an array from a Replicator
. To test the Replicator
API.
data RepStream a where | ||
RepStream :: (s %1 -> a) -> (s %1 -> (s, s)) -> (s %1 -> ()) -> s %1 -> RepStream a | ||
|
||
data Replicator a where | ||
Moved :: a -> Replicator a | ||
CollectFrom :: RepStream a %1 -> Replicator a |
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.
You don't have access to the Applicative
class at this point†, but you should have a pure
and a (<*>)
function nonetheless. For both types.
We will probably need other functions, like a function Replicator %1 -> RepStream
.
† Sometimes I feel as though this library should all be one big Internal
file where everything is mutually recursive, and then we use the file hierarchy purely for exports.
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.
Random thought: should we use unboxed pairs (and unit) in the projections? Maybe it'll be better?
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.
If we use unboxed tuple for the dups
projector, then it becomes harder to write dupR
in terms of dup2
(or we should also change the dup2
signature to use unboxed tuples).
I don't know how to write an unboxed unit, but if we return some in the consumes
projector, then writing consume
(from Consumable
) for ReplicationStream
is also less trivial.
I also tried to use unboxed tuples in the Applicative
instance for ReplicationStream
(for <*>
), but AFAIK, it's not possible because the projections cannot receive an unboxed tuple as a function parameter.
Also, without 9.2, I don't see how we can actually write this:
dupsf sf' & \case
(# sf1, sf2 #)
We need the func_call & lambda_case
syntax here for linearity, but because the result of the function call is now passed as an argument to &
, then unboxed tuples are not allowed in that position.
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.
Unboxed unit is (##)
.
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.
Well, let's wait 9.2 before we decide to revisit this issue, then. It's not worth agonising over.
I pushed a little something to restore the backward functional As I see it, there are two solutions:
While (1) is definitely the simpler solution, I went for (2) in my What this implied is making a type family What I don't know if why I had to add |
Should I redefine Also, I was wondering yesterday, could we add a |
I guess it's better to use the same. Either way, it gives some pretty unappealing types, so we will have to give pretty solid documentation to
Unfortunately it wouldn't work. GHC only looks at the instance's head (the part to the right of the |
Do you see where we could but the
I would have used something like |
I guess. There is no good place where to put it anyway. The relation with |
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 came to have some fun explaining the code. I shared some suggestions for documentation that I think could be helpful.
I should add: this is another PR that got bigger than we planned. We should be more careful for the next ones. |
Why are we deriving Prelude (non-linear) versions of |
3d5b286
to
eec651f
Compare
I don't remember for sure. But if I had to guess, it's because we wanted elim :: forall p n a b. (a %p -> … %p -> b) %1 -> V n a %p -> b |
…iscoverable
4da2e78
to
fc009e6
Compare
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've got some comments on the documentation. You can address them then merge.
Co-authored-by: Arnaud Spiwack <[email protected]>
No description provided.