Skip to content

Instantly share code, notes, and snippets.

@adamchester
Last active July 4, 2018 00:25

Revisions

  1. adamchester revised this gist Feb 24, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion states.fs
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    type State = Initial | Draft | PendingApproval | Approved | Cancelled | Completed
    type Action = | Create | Cancel | SendForApproval | Approve | Reject | Complete
    type Action = Create | Cancel | SendForApproval | Approve | Reject | Complete
    type Role = Creator | Approver | Completor
    type Transition = { Action:Action; From:State; To:State; Roles:Role list }
    module Transitions =
  2. adamchester revised this gist Feb 24, 2015. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion states.fs
    Original file line number Diff line number Diff line change
    @@ -13,7 +13,6 @@ module Transitions =

    Transitions.all
    |> List.mapi (fun i t -> i, t.Action, t.From, t.To, t.Roles)
    |> printfn "%A"

    (*
    val it : (int * Action * State * State * Role list) list =
  3. adamchester revised this gist Feb 24, 2015. 1 changed file with 6 additions and 5 deletions.
    11 changes: 6 additions & 5 deletions states.fs
    Original file line number Diff line number Diff line change
    @@ -17,9 +17,10 @@ Transitions.all

    (*
    val it : (int * Action * State * State * Role list) list =
    [(0, Create, Initial, Draft, [Creator]);
    (1, SendForApproval, Draft, PendingApproval, [Creator]);
    (2, Approve, PendingApproval, Approved, [Approver]);
    (3, Reject, PendingApproval, Draft, [Approver]);
    (4, Complete, Approved, Completed, [Completor])]
    [(0, Create, Initial, Draft, [Creator]);
    (1, SendForApproval, Draft, PendingApproval, [Creator]);
    (2, Approve, PendingApproval, Approved, [Approver]);
    (3, Reject, PendingApproval, Draft, [Approver]);
    (4, Complete, Approved, Completed, [Completor]);
    (5, Cancel, Draft, Cancelled, [Creator])]
    *)
  4. adamchester revised this gist Feb 24, 2015. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions states.fs
    Original file line number Diff line number Diff line change
    @@ -1,15 +1,15 @@

    type State = Initial | Draft | PendingApproval | Approved | Cancelled | Completed
    type Action = | Create | Cancel | SendForApproval | Approve | Reject | Complete
    type Role = Creator | Approver | Completor
    type Transition = { Action:Action; From:State; To:State; Roles:Role list }
    module Transitions =
    let create = { Action=Create; From=Initial; To=Draft; Roles=[ Creator ] }
    let cancel = { Action=Cancel; From=Draft; To=Cancelled; Roles=[ Creator ] }
    let sendForAppr = { Action=SendForApproval; From=Draft; To=PendingApproval; Roles=[ Creator ] }
    let approve = { Action=Approve; From=PendingApproval; To=Approved; Roles=[ Approver ] }
    let reject = { Action=Reject; From=PendingApproval; To=Draft; Roles=[ Approver ] }
    let complete = { Action=Complete; From=Approved; To=Completed; Roles=[ Completor ] }
    let all = [ create; sendForAppr; approve; reject; complete ]
    let all = [ create; sendForAppr; approve; reject; complete; cancel; ]

    Transitions.all
    |> List.mapi (fun i t -> i, t.Action, t.From, t.To, t.Roles)
  5. adamchester revised this gist Feb 24, 2015. 1 changed file with 10 additions and 8 deletions.
    18 changes: 10 additions & 8 deletions states.fs
    Original file line number Diff line number Diff line change
    @@ -1,17 +1,19 @@

    type State = Initial | Draft | PendingApproval | Approved | Cancelled | Completed
    type Action = Create | Cancel | SendForApproval | Approve | Reject | Complete
    type Action = | Create | Cancel | SendForApproval | Approve | Reject | Complete
    type Role = Creator | Approver | Completor
    type Transition = { Action:Action; From:State; To:State; Roles:Role list }
    let myWorkflow = [
    { Action=Create; From=Initial; To=Draft; Roles=[ Creator ] }
    { Action=SendForApproval; From=Draft; To=PendingApproval; Roles=[ Creator ] }
    { Action=Approve; From=PendingApproval; To=Approved; Roles=[ Approver ] }
    { Action=Reject; From=PendingApproval; To=Draft; Roles=[ Approver ] }
    { Action=Complete; From=Approved; To=Completed; Roles=[ Completor ] } ]
    module Transitions =
    let create = { Action=Create; From=Initial; To=Draft; Roles=[ Creator ] }
    let sendForAppr = { Action=SendForApproval; From=Draft; To=PendingApproval; Roles=[ Creator ] }
    let approve = { Action=Approve; From=PendingApproval; To=Approved; Roles=[ Approver ] }
    let reject = { Action=Reject; From=PendingApproval; To=Draft; Roles=[ Approver ] }
    let complete = { Action=Complete; From=Approved; To=Completed; Roles=[ Completor ] }
    let all = [ create; sendForAppr; approve; reject; complete ]

    myWorkflow
    Transitions.all
    |> List.mapi (fun i t -> i, t.Action, t.From, t.To, t.Roles)
    |> printfn "%A"

    (*
    val it : (int * Action * State * State * Role list) list =
  6. adamchester created this gist Feb 24, 2015.
    23 changes: 23 additions & 0 deletions states.fs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@

    type State = Initial | Draft | PendingApproval | Approved | Cancelled | Completed
    type Action = Create | Cancel | SendForApproval | Approve | Reject | Complete
    type Role = Creator | Approver | Completor
    type Transition = { Action:Action; From:State; To:State; Roles:Role list }
    let myWorkflow = [
    { Action=Create; From=Initial; To=Draft; Roles=[ Creator ] }
    { Action=SendForApproval; From=Draft; To=PendingApproval; Roles=[ Creator ] }
    { Action=Approve; From=PendingApproval; To=Approved; Roles=[ Approver ] }
    { Action=Reject; From=PendingApproval; To=Draft; Roles=[ Approver ] }
    { Action=Complete; From=Approved; To=Completed; Roles=[ Completor ] } ]

    myWorkflow
    |> List.mapi (fun i t -> i, t.Action, t.From, t.To, t.Roles)

    (*
    val it : (int * Action * State * State * Role list) list =
    [(0, Create, Initial, Draft, [Creator]);
    (1, SendForApproval, Draft, PendingApproval, [Creator]);
    (2, Approve, PendingApproval, Approved, [Approver]);
    (3, Reject, PendingApproval, Draft, [Approver]);
    (4, Complete, Approved, Completed, [Completor])]
    *)