Skip to content

WrappedArrow instances: Category, Arrow, ArrowZero, ArrowPlus

Should Control.Applicative.WrappedArrow have Category and Arrow instances

newtype WrappedArrow arr a b = WrapArrow (arr a b)
  deriving
  newtype (Category, Arrow, ArrowZero, ArrowPlus)

It would reduce newtype cruft, but the instances are not necessary otherwise. I am curious where the line is drawn for adding instances to modifier types

  fmap f       = (>>> arr f)  -- fmap = (^<<)
  pure         = arr . const
  liftA2 f u v = u &&& v >>> arr (uncurry f)
  empty        = zeroArrow
  (<|>)        = (<+>)

instead of

  fmap f (WrapArrow a) = WrapArrow (a >>> arr f)
  pure x = WrapArrow (arr (const x))
  liftA2 f (WrapArrow u) (WrapArrow v) = WrapArrow (u &&& v >>> arr (uncurry f))
  empty = WrapArrow zeroArrow
  WrapArrow u <|> WrapArrow v = WrapArrow (u <+> v)
Edited by Icelandjack
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information