[GHC] #5267: Arrow command combinators

GHC cvs-ghc at haskell.org
Wed Oct 12 08:34:12 CEST 2011


#5267: Arrow command combinators
----------------------------------------+-----------------------------------
  Reporter:  peteg                      |          Owner:                  
      Type:  bug                        |         Status:  new             
  Priority:  normal                     |      Milestone:  7.4.1           
 Component:  Compiler                   |        Version:  7.0.3           
Resolution:                             |       Keywords:                  
  Testcase:                             |      Blockedby:                  
Difficulty:                             |             Os:  Unknown/Multiple
  Blocking:                             |   Architecture:  Unknown/Multiple
   Failure:  GHC rejects valid program  |  
----------------------------------------+-----------------------------------

Comment(by peteg):

 Ross,

 Here's another couple of bugs.

 {{{
 module B where

 import Prelude
 import Control.Arrow
 import Control.Category

 -- Some Arrow transformer.
 newtype A (~>) b c = A { unA :: b ~> c }
   deriving (Arrow, Category)

 -- Determine the condition in the underlying Arrow.
 ite :: ArrowChoice (~>) => (env ~> Bool) -> A (~>) env d -> A (~>) env d
 -> A (~>) env d
 ite iA tA eA = A $ proc env ->
   do i <- iA -< env
      if i then unA tA -< env else unA eA -< env

 -- Bug: moving ite_perm out of the where block works.
 {-
 ite' cA tA eA = proc x ->
   do c <- cA -< x
      (| ite_perm (returnA -< c) |)
   where ite_perm i = ite i tA eA


     The type of the first argument of a command form has the wrong shape
       Argument type: t_tz
     In the command: (|ite_perm ((returnA -< c))|)
     In the expression:
       proc x -> do { c <- cA -< x;
                      (|ite_perm ((returnA -< c))|) }
     In an equation for `ite'':
         ite' cA tA eA
           = proc x -> do { c <- cA -< x;
                            (|ite_perm ((returnA -< c))|) }
 -}

 ite' cA tA eA = proc x ->
   do c <- cA -< x
      (| (ite_perm tA eA) (returnA -< c) |)

 ite_perm tA eA i = ite i tA eA

 -- Bug: we can't write the type signature we want.
 -- ite' :: ArrowChoice (~>) => A (~>) env Bool -> A (~>) env d -> A (~>)
 env d -> A (~>) env d

 {-

     Warning: Top-level binding with no type signature:
                ite' :: forall a t t1 (t2 :: * -> * -> *).
                         ArrowChoice t2 =>
                         A t2 t1 Bool -> A t2 a t -> A t2 a t -> A t2 t1 t

 I want to set a = t1.

 -}
 }}}

 The motivation is where ite is a lot more complex than it is here, and I
 don't want to repeat it in ite'. It is supposed to be a small
 optimisation, i.e. avoiding lift and (>>>) in A.

 Perhaps these are fixed in a more recent GHC than 7.0.3.

 cheers

 peter

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5267#comment:5>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler



More information about the Glasgow-haskell-bugs mailing list