Conversation
|
I'm sure everything is in the wrong place and some of the names are bad, but this seems to work quite nicely. |
`genericTraverse` is an efficient implementation of `traverse` for any `Generic1` type.
778cbe1 to
b48778b
Compare
|
I don't know what has to happen to fix the Stack build. Tried and failed. |
| {-# INLINE gtraverse #-} | ||
|
|
||
| instance GTraversable V1 where | ||
| gtraverse _ v = pure ((\case) v) |
There was a problem hiding this comment.
This is the way it's normally done in base. We could also match (fail) eagerly.
There was a problem hiding this comment.
(I actually prefer the stricter way myself; just don't want to break expectations without buy-in.)
There was a problem hiding this comment.
Do you have strong arguments either way? If not, let's probably leave it as it is in base.
There was a problem hiding this comment.
Strict lawfulness is my main argument, and I'll admit that's not terribly strong. It'll likely eliminate a little code as dead.
|
Hey, thanks for the PR!
It was a minor fix, the As about this PR, it looks neat to me; but @aspiwack or @sjoerdvisscher is much better informed than me in this area, so I'm refraining from reviewing it. |
|
Thanks, @utdemir! |
aspiwack
left a comment
There was a problem hiding this comment.
Should this PR introduce a combinator so that Traversable can be derived with deriving-via?
@sjoerdvisscher can you give this a review?
@treeowl I'm giving you the write bit, so that you can merge when the reviews are completed.
| -- Traversable instances. | ||
| module Control.Functor.Linear.Internal.Kan where | ||
| import Control.Functor.Linear | ||
| import qualified Data.Functor.Linear as D |
There was a problem hiding this comment.
| import qualified Data.Functor.Linear as D | |
| import qualified Data.Functor.Linear as Data |
In this package, there is no single-letter import 🙂
|
@aspiwack, |
Ah well… this is quite unfortunate. Who would have thought, when deriving-via landed that we'd run into role issues so often? |
It's possible to modify the type of class (Functor t, Foldable t) => Traversable t where
traverseThen :: Applicative f => (t b -> r) -> (a -> f b) -> t a -> f r
traverseThen t f = fmap t . traverseCoerce f
traverseCoerce :: (Applicative f, Coercible (t b) r) => (a -> f b) -> t a -> f r
traverseCoerce = traverseThen coerce |
|
Let's not go there for the moment. |
|
My biggest concern is that performance of generic |
|
I think that we can close it now that #366 is merged. |
|
Yes. Let's close thank you both! |
genericTraverseis an efficient implementation oftraverseforany
Generic1type.