Open joneshf opened 5 years ago
So the error is indeed in extend, where I didn't propagate the function to the tail of the list.
My first thought was to write something like List a -> Optional (NonEmptyList a)
. Then do maybe [] (toList . extend f) (fromList nel.tail)
But I'm not sure how to a) write fromList
and b) get around not being able to do recursion with extend
there.
One option may be to define NonEmptyList
in terms of recursion schemes (dada cc @sellout).
If we can't fix this in bhat then we need to remove this instance entirely.
EDIT: Fixed pseudocode
@monoidmusician and I were discussing
NonEmptyList/comonad
in slack, and it seems like it's not working as intended. In particular, thetail
is always an empty list. It seems like the coherence withFunctor
doesn't match. We hope thatmap f x = extend (\x -> f (extract x)) x
, but it doesn't seem to:I was going to send a PR, but
extend
always throws me for a loop. So if someone wants to PR, go for it.