Changes between Initial Version and Version 1 of Ticket #7828, comment 17


Ignore:
Timestamp:
Jun 17, 2014 5:13:33 PM (5 years ago)
Author:
ross
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #7828, comment 17

    initial v1  
    11Here's a different suggestion for rebinding that is perhaps more analogous to the expression case.  We could consider do and if commands as sugar for more primitive commands:
    22{{{
    3 do { p <- cmd; stmts } = cmd `bind` \ p -> do { stmts }
    4 do { cmd; stmts } = cmd `bind_` do { stmts }
    5 do { let defs; stmts } = let defs in do { stmts }
     3do { p <- cmd; ss } = cmd `bind` \ p -> do { ss }
     4do { cmd; ss } = cmd `bind_` do { ss }
     5do { rec { ss }; ss' } =
     6    do { vs <- (| fixA (\ ~vs -> do { ss; returnA -< vs })|); ss' }
     7do { let defs; ss } = let defs in do { ss }
    68do { cmd } = cmd
    79if exp then cmd1 else cmd2 = (| ifThenElseA cmd1 cmd2 |) exp
     
    1517u `bind_` v = arr id &&& u >>> arr fst >>> v
    1618
     19fixA :: ArrowLoop a => a (e,(b,s)) b -> a (e,s) b
     20fixA f = loop (arr (\ ((e,s),b) -> (e,(b,s))) >>> f >>> arr (\ b -> (b,b)))
     21
    1722ifThenElseA :: ArrowChoice a => a (e,s) r -> a (e,s) r -> a (e,(Bool,s)) r
    1823ifThenElseA thenPart elsePart = arr split >>> thenPart ||| elsePart