[GHC] #5267: Arrow command combinators
GHC
cvs-ghc at haskell.org
Tue Nov 8 12:44:30 CET 2011
#5267: Arrow command combinators
------------------------------------------+---------------------------------
Reporter: peteg | Owner: ross
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 accepts invalid program |
------------------------------------------+---------------------------------
Comment(by ross):
Here are some examples from our desugaring discussion, which may or may
not help.
{{{
add :: Arrow a => a b Int -> a b Int -> a b Int
add f g = proc z ->
(f -< z) `bind` \ x ->
(g -< z) `bind` \ y ->
returnA -< x+y
bind :: Arrow a => a e b -> a (e, b) c -> a e c
u `bind` f = arr Prelude.id &&& u >>> f
}}}
Here we have infix `ArrForm`s with `bind` as the function.
{{{
ite :: ArrowChoice a => a env Bool -> a env d -> a env d -> a env d
ite iA tA eA = proc env ->
(iA -< env) `bind` \ i ->
(| ifThenElseA (tA -< env) (eA -< env) |) i
ifThenElseA :: ArrowChoice a => a e r -> a e r -> a (e, Bool) r
ifThenElseA thenPart elsePart = arr split >>> thenPart ||| elsePart
where
split (e, True) = Left e
split (e, False) = Right e
}}}
In these cases one can see the arity from the code, but one can also eta-
contract the above to
{{{
ite' :: ArrowChoice a => a env Bool -> a env d -> a env d -> a env d
ite' iA tA eA = proc env ->
(iA -< env) `bind` (| ifThenElseA (tA -< env) (eA -< env) |)
}}}
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5267#comment:15>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the Glasgow-haskell-bugs
mailing list