Cindiary/elm-id

Basic opaque ID type


License
BSD-3-Clause
Install
elm-package install Cindiary/elm-id 2.0.1

Documentation

Elm ID is a library for making opaque ID types that can be used in dictionaries.

Example

module User exposing (User, ID, newCounter, newUser)

import ID
import ID.Counter

type alias ID =
    ID.ID IDInternal

type IDInternal
    = IDInternal

type alias User =
    { id : ID
    , name : String
    }


newCounter : ID.Counter ID
newCounter =
    ID.Counter.new IDInternal


newUser : ID.Counter -> String -> ( ID.Counter, User )
newUser counter name =
    let
        ( id, newCounter ) = ID.Counter.newID counter
    in
    ( newCounter, { id = id, name = name } )