Open viercc opened 2 years ago
To copy it out here, this is an alternate, explicit implementation:
left (Cokleisli f) = Cokleisli (\fac ->
case extract fac of
Right c -> Right c
Left a -> Left . f $ fmap (either id (const a)) fac)
which has also been mentioned in a few other forums. I have previously verified that it meets the definition for co-cartesian co-strength manually, and it appears that these could be equivalent to the laws for Choice at first glance, and likewise this should meet the laws, although it would be a breaking change in the implementation.
It's not clear why the implementation would appear to not be the same, if the linked issue is to be believed.
The instance
instance Comonad w => Choice (Cokleisli w)
doesn't follow theChoice
laws. It would have been ifCokleisli w
was a conformingArrowChoice
, but it isn't (although it has the instance.)https://github.com/ekmett/comonad/issues/36
Maybe it's already alarmed by the notice
'extract' approximates 'costrength'
attached to theChoice
instance, but it wasn't clear for me.