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

GHC ghc-devs at haskell.org
Thu Dec 22 01:15:21 UTC 2016


#13026: RFC functions for sums and products
-------------------------------------+-------------------------------------
        Reporter:  Iceland_jack      |                Owner:
            Type:  feature request   |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  libraries/base    |              Version:  8.0.1
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------
Description changed by Iceland_jack:

@@ -6,1 +6,1 @@
- {{{!hs
+ {{{#!hs

New description:

 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#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list