Database.Sequence
Database
Database sequences for monotonic primary keys and similar identifiers. Declare them in a database module alongside tables; allocate with next inside a Transaction.
Types
Sequence
type Sequence a = SequenceA named sequence that yields values of type a.
Examples
todoIDs : Sequence TodoID
todoIDs :=
Seq.uint64 TodoIDValues
next
next : Sequence a -> Transaction aAllocate the next value from a sequence.
Examples
Seq.next todoIDs
|> andThen
(\id ->
insert todos user { id = id, owner = user, title = title, completed = False }
)uint8
uint8 : (UInt8 -> a) -> Description (Sequence a)Declare an 8-bit unsigned integer sequence.
Examples
type TagID = TagID UInt8
tagIDs :=
Seq.uint8 TagIDuint16
uint16 : (UInt16 -> a) -> Description (Sequence a)Declare a 16-bit unsigned integer sequence.
Examples
type ColorID = ColorID UInt16
colorIDs :=
Seq.uint16 ColorIDuint32
uint32 : (UInt32 -> a) -> Description (Sequence a)Declare a 32-bit unsigned integer sequence.
Examples
type PostID = PostID UInt32
postIDs :=
Seq.uint32 PostIDuint64
uint64 : (UInt64 -> a) -> Description (Sequence a)Declare a 64-bit unsigned integer sequence.
Examples
type TodoID = TodoID UInt64
todoIDs :=
Seq.uint64 TodoID