Conversation
|
This and part 1 looks promising to me! I think |
| foldWith f (Array k) = k f | ||
|
|
||
| unzip :: Array (a,b) %1-> (Array a, Array b) | ||
| unzip = undefined |
There was a problem hiding this comment.
| unzip = undefined | |
| unzip (Array k) = k (\(a, b) -> (singleton a, singleton b)) |
This kind of make sense to me, but I'm unsure (both semantically and performance-wise).
There was a problem hiding this comment.
That's very clever and I feel dumb for not coming up with it after messing with it for a while, lol 😸
It does make sense: k is something that takes something that writes an a to a monoid that represents a composable way to write an a to a cell of an array. Here, k takes something that changes (a,b) to a monoidal-computation that writes an (a,b) to a cell of an array.
This implementation in words says "a way to write each pair of (a,b) into a monoidal writing-computation is to have a pair of monoidal writing-computations". If you give this to k it will make a bunch of pairs of singletons and concatenate them.
| cons x (Array k) = Array (\writeA -> (writeA x) <> (k writeA)) | ||
|
|
||
| foldWith :: Monoid b => (a -> b) -> Array a %1-> b | ||
| foldWith f (Array k) = k f |
There was a problem hiding this comment.
This function is foldMap (specialized to Array and with a linear arrow), so I think we should call it that.
The Foldable/Traversable issues are likely relevant, but those assume the first parameter to be linear too. Bit unfortunate that we don't have a typeclass for this.
| {-# OPTIONS_GHC -Wno-orphans #-} | ||
| {-# LANGUAGE DerivingVia #-} | ||
| {-# LANGUAGE GADTs #-} | ||
| {-# LANGUAGE TypeInType #-} |
There was a problem hiding this comment.
I don't think we need this.
There was a problem hiding this comment.
Remnants from my testing.
| @@ -1,5 +1,7 @@ | |||
| {-# OPTIONS_GHC -Wno-orphans #-} | |||
There was a problem hiding this comment.
This also doesn't seem to be necessary.
There was a problem hiding this comment.
Remnants from my testing.
d14273f to
5c08147
Compare
5c08147 to
5b83d75
Compare
5b83d75 to
43d4af5
Compare
|
🎉 All dependencies have been resolved ! |
Summary
This PR adds to push arrays:
Depends on #287.
Things I don't fully understand