database :: Config ()
database = Config {
       cTypes = [ makeType0 "Set"
                , makeType0 "Value"
                , makeType1 "Get"
                ]
     , cSets = []
     , cUnfold = [Conc (S "ps") 1]
     , cProcs = [ (db, dbProc)
                , (ps, psProc)
                , (me, meProc)
                ]
     }
  where
    ps = PAbs (V "p") (S "ps")
    db = PConc 0
    me = PConc 1
    makeType0 t = MTApp (MTyCon t) []
    makeType1 t = MTApp (MTyCon t) [PVar (V "x")]
    val1 t v    = MTApp (MTyCon t) [v]

    psProc = Loop (LV "endX")
               (Recv [ (makeType0 "Set", Goto (LV "endX") ())
                      , (makeType1 "Get", Send (PVar (V "x")) [(makeType0 "Value", Goto (LV "endX") ())] ())
                      ] ())
               ()

    dbProc = Loop (LV "endX")
               (Recv [ (makeType0 "Set", Choose (V "y") (S "ps") (Send (PVar (V "y")) [(makeType0 "Set", Goto (LV "endX") ())] ()) ())
                      , (makeType1 "Get", Choose (V "y") (S "ps") (Send (PVar (V "y")) [(makeType1 "Get", Goto (LV "endX") ())] ()) ())
                      ] ())
               ()

    meProc = Loop (LV "endX")
               (Send db [ (makeType0 "Set", Goto (LV "endX") ())
                         , (val1 "Get" me, Recv [ (makeType0 "Value", Goto (LV "endX") ()) ] ())
                         ] ())
               ()
database :: Config ()
database = Config {
       cTypes = [ makeType0 "Set"
                , makeType0 "Value"
                , makeType1 "Get"
                ]
     , cSets = []
     , cUnfold = [Conc (S "ps") 1]
     , cProcs = [ (db, dbProc)
                , (ps, psProc)
                , (me, meProc)
                ]
     }
  where
    ps = PAbs (V "p") (S "ps")
    db = PConc 0
    me = PConc 1
    makeType0 t = MTApp (MTyCon t) []
    makeType1 t = MTApp (MTyCon t) [PVar (V "x")]
    val1 t v    = MTApp (MTyCon t) [v]

    psProc = Loop (LV "endX")
               (Recv [ (makeType0 "Set", Goto (LV "endX") ())
                      , (makeType1 "Get", Send (PVar (V "x")) [(makeType0 "Value", Goto (LV "endX") ())] ())
                      ] ())
               ()

    dbProc = Loop (LV "endX")
               (Recv [ (makeType0 "Set", Choose (V "y") (S "ps") (Send (PVar (V "y")) [(makeType0 "Set", Goto (LV "endX") ())] ()) ())
                      , (makeType1 "Get", Choose (V "y") (S "ps") (Send (PVar (V "y")) [(makeType1 "Get", Goto (LV "endX") ())] ()) ())
                      ] ())
               ()

    meProc = Loop (LV "endX")
               (Send db [ (makeType0 "Set", Goto (LV "endX") ())
                         , (val1 "Get" me, Recv [ (makeType0 "Value", Goto (LV "endX") ()) ] ())
                         ] ())
               ()
database = Config {
       cTypes = [ makeType0 "Set"
                , makeType0 "Value"
                , makeType1 "Get"
                ]
     , cSets = []
     , cUnfold = [Conc (S "ps") 1]
     , cProcs = [ (db, dbProc)
                , (ps, psProc)
                , (me, meProc)
                ]
     }
  where
    ps = PAbs (V "p") (S "ps")
    db = PConc 0
    me = PConc 1
    makeType0 t = MTApp (MTyCon t) []
    makeType1 t = MTApp (MTyCon t) [PVar (V "x")]
    val1 t v    = MTApp (MTyCon t) [v]

    psProc = Loop (LV "endX")
               (Recv [ (makeType0 "Set", Goto (LV "endX") ())
                      , (makeType1 "Get", Send (PVar (V "x")) [(makeType0 "Value", Goto (LV "endX") ())] ())
                      ] ())
               ()

    dbProc = Loop (LV "endX")
               (Recv [ (makeType0 "Set", Choose (V "y") (S "ps") (Send (PVar (V "y")) [(makeType0 "Set", Goto (LV "endX") ())] ()) ())
                      , (makeType1 "Get", Choose (V "y") (S "ps") (Send (PVar (V "y")) [(makeType1 "Get", Goto (LV "endX") ())] ()) ())
                      ] ())
               ()

    meProc = Loop (LV "endX")
               (Send db [ (makeType0 "Set", Goto (LV "endX") ())
                         , (val1 "Get" me, Recv [ (makeType0 "Value", Goto (LV "endX") ()) ] ())
                         ] ())
               ()