What would be the methods of a bi-comonad?

后端 未结 1 1192
忘掉有多难
忘掉有多难 2021-02-20 06:27

While musing what more useful standard class to suggest to this one

class Coordinate c where
  createCoordinate :: x -> y -> c x y
  getFirst :: c x y ->         


        
1条回答
  •  暖寄归人
    2021-02-20 07:28

    This is not an answer, but for Bimonad, how about this?

    class Biapplicative p => Bimonad p where
      (>>==) :: p a b -> (a -> b -> p c d) -> p c d
    
    biap :: Bimonad p => p (a -> b) (c -> d) -> p a c -> p b d
    biap p q = p >>== \ab cd -> q >>== \a c -> bipure (ab a) (cd c)
    
    instance Bimonad (,) where
      (a,b) >>== f = f a b
    

    I don't know if this is categorically right/interesting, or even remotely useful, but it smells right from a Haskell perspective. Does it match your Bicomonad or something similar?

    0 讨论(0)
提交回复
热议问题