[GHC] #13026: RFC functions for sums and products

GHC ghc-devs at haskell.org
Thu Dec 22 01:14:38 UTC 2016


#13026: RFC functions for sums and products
-------------------------------------+-------------------------------------
           Reporter:  Iceland_jack   |             Owner:
               Type:  feature        |            Status:  new
  request                            |
           Priority:  normal         |         Milestone:
          Component:                 |           Version:  8.0.1
  libraries/base                     |
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 I'll ask on the libraries mailing list depending on feedback.

 Adding these to `Data.Functor.Sum`, `Data.Functor.Product` a la
 `Control.Arrow`

 {{{!hs
 (||||) :: (f a -> b) -> (g a -> b) -> ((Sum f g) a -> b)
 f |||| g = \case
   InL fa -> f fa
   InR ga -> g ga

 (&&&&) :: (a -> f b) -> (a -> g b) -> (a -> (Product f g) b)
 (f &&&& g) a = f a `Pair` g a
 }}}

 `||||` is used in "Monad transformers and modular algebraic effects: What
 binds them together" in section 2.4, the names are up for discussion

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13026>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list