Skip to content

Instantly share code, notes, and snippets.

@dcapwell
Created February 4, 2016 07:08
Show Gist options
  • Save dcapwell/276232d980e8dd76db91 to your computer and use it in GitHub Desktop.
Save dcapwell/276232d980e8dd76db91 to your computer and use it in GitHub Desktop.
module Tracker where
---- MODEL ----
type alias Dashboard =
{ name : String
, active : Bucket
, pending : Bucket
, icebox : Bucket }
type BucketType
= Active
| Pending
| Icebox
type alias Bucket =
{ title : String
, description : String
, issues : List Issue }
type alias Issue =
{ iid : Int
, title : String
, description : String
, state : State
, labels : List String}
type State
= Open
| Closed
type alias User = String
initialDashboard : Dashboard
initialDashboard =
{ name = "Primary"
, active = emptyBucket "Active" "Issues under active development"
, pending = emptyBucket "Pending" "High priority issues that are not in active development"
, icebox = emptyBucket "Icebox" "Low priority, unordered issues" }
emptyBucket : String -> String -> Bucket
emptyBucket title description =
{ title = title
, description = description
, issues = [] }
newIssue : Int -> String -> String -> State -> List String -> Issue
newIssue iid title description state labels =
{ iid = iid
, title = title
, description = description
, state = state
, labels = labels }
---- UPDATE ----
type Action
= NoOp
| Add BucketType Issue
update : Action -> Dashboard -> Dashboard
update action dashboard =
case action of
NoOp -> dashboard
Add t issue ->
case t of
Active -> { dashboard | action = dashboard.action ++ [ issue ] }
Pending -> { dashboard | pending = dashboard.pending ++ [ issue ] }
Icebox -> { dashboard | icebox = dashboard.icebox ++ [ issue ] }
@gyzerok
Copy link

gyzerok commented Feb 4, 2016

You can rename file to Tracker.elm, so there would be syntax highlight.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment