[GHC] #7828: RebindableSyntax and Arrow

GHC ghc-devs at haskell.org
Thu Jul 10 12:47:58 UTC 2014


#7828: RebindableSyntax and Arrow
----------------------------------------------+----------------------------
        Reporter:  AlessandroVermeulen        |            Owner:
            Type:  bug                        |  jstolarek
        Priority:  normal                     |           Status:  new
       Component:  Compiler (Type checker)    |        Milestone:  7.10.1
      Resolution:                             |          Version:  7.6.2
Operating System:  Unknown/Multiple           |         Keywords:
 Type of failure:  GHC rejects valid program  |     Architecture:
       Test Case:                             |  Unknown/Multiple
        Blocking:                             |       Difficulty:  Unknown
                                              |       Blocked By:
                                              |  Related Tickets:  #1537,
                                              |  #3613
----------------------------------------------+----------------------------

Comment (by jstolarek):

 I have made some progress on this one today. I'm able to compile

 {{{
 test :: Arrow a => a i i
 test = proc n -> do
          returnA -< n
 }}}

 using the new desugaring, which was not possible earlier. But I'm still
 stuck on this:

 {{{
 test :: Arrow a => a i i
 test = proc n -> do
          returnA -< n
          returnA -< n
 }}}

 ie. desugaring of `thenA` although now I have gathered more information.
 With my new implementation the code above desugars to:

 {{{
 (>>>) @ i @ (i, ()) @ i
   (arr @ i @ (i, ()) (\ (n :: i) -> (n, ())))
   (thenA @ arrow @ i @ (GHC.Prim.Any *) @ (GHC.Prim.Any *) @ i $dArrow_auX
      ((>>>) @ (i, ()) @ i @ i
         (arr @ (i, ()) @ i
            (\ (ds2 :: (i, ())) ->
               case ds2 of _ { (ds4, ds5) -> ds4 }))
         (Control.Arrow.returnA @ arrow @ i $dArrow_auX))
      ((>>>) @ (i, ()) @ i @ i
         (arr @ (i, ()) @ i
            (\ (ds2 :: (i, ())) ->
               case ds2 of _ { (ds4, ds5) -> ds4 }))
         (Control.Arrow.returnA @ arrow @ i $dArrow_auX)))
 }}}

 This looks correct except for the two `(GHC.Prim.Any *)` type parameters
 to `thenA`. One corresponds to the type of the stack, the other to result
 of first command (`b` in the type signature `a (e,s) b -> a (e,s) c -> a
 (e,s) c`). `thenA` should be polymorphic in these, but it seems that
 during typechecking I need to instantiate `s` and `b` to concrete values.
 I noticed that desugaring of `cmd` stored in the `BodyStmt` always passes
 `()` as the type of the stack. If this is correct then there's only the
 problem of what to do with `b`. Help needed here becuase I have no idea
 how to figure out the type of `b` from within `tcArrDoStmt`.

 Ross, I also tried to implement desugaring of `bind`. When generating the
 desugared Core for `cmd 'bind' \ p -> do { ss }` I have problem with the
 `\p ->` part. So, given the desugared `do { ss }`, `cmd` and the `bind`
 operator how should the generated command lambda look like? I'm still at a
 loss to undestand how to explicitly manipulate the stack from within Core.

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


More information about the ghc-tickets mailing list