joneshf/elm-tagged/1.0.0

NOTE: this package is not compatible with Elm 0.19.1

Tagged

A module that allows you to "tag" a value.

type Tagged tag value
= Tagged value

A Type that pairs a value with a tag.

The tag is ignored at runtime as evidenced by the only value constructor:

Tagged : value -> Tagged tag value
tag : value -> Tagged tag value

An alias for the Tagged value constructor.

retag : Tagged oldTag value -> Tagged newTag value

Explicitly changes the tag of a value.

Forces you to recognize that the value is being interpreted differently from before.

untag : Tagged tag value -> value

We can remove the tag when we're done making additional compile-time assertions.

map : (oldValue -> newValue) -> Tagged tag oldValue -> Tagged tag newValue

Useful for composing functions together infix:

foo =
  Array.set `map` index `ap` value `ap` arr
ap :
Tagged tag (oldValue -> newValue)
-> Tagged tag oldValue
-> Tagged tag newValue

Useful for composing functions together infix:

foo =
  Array.set `map` index `ap` value `ap` arr
(oldValue -> Tagged tag newValue)
-> Tagged tag oldValue
-> Tagged tag newValue

Useful for restricting the tag created in a polymorphic function.

(Tagged tag oldValue -> newValue)
-> Tagged tag oldValue
-> Tagged tag newValue

Useful when you have a function that throws away a tag prematurely, but you still need the tag later.