aboutsummaryrefslogtreecommitdiff
path: root/src/Model/IdGenerator.elm
blob: ba760d8277d4dd9f35588048365dfc60702335a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
module Model.IdGenerator
  ( IdGenerator
  , initialIdGenerator
  , getId
  ) where

import Model.Id (..)

type alias IdGenerator =
  { counter : Id
  }

initialIdGenerator =
  { counter = 1
  }

getId : IdGenerator -> (Id, IdGenerator)
getId idGenerator =
  ( idGenerator.counter
  , { idGenerator | counter <- idGenerator.counter + 1 }
  )