Uptight.Text (Uptight v0.2.2-rc)

Newtype for textual data.

It does what you expect, except it has one peculiarity:

  • map just applies function to the underlying binary string as is
  • right_fold and other folds from Foldable iterate through UTF-8 characters

This behaviour probably should be unified to work over UTF-8 characters one way or another and a custom class Newtype should be devised to provide naive fmap functionality.

Link to this section Summary

Functions

Default Elixir.Uptight.Text struct

Defensive constructor.

Offensive constructor.

Link to this section Types

Specs

t() :: %Uptight.Text{text: binary()}

Link to this section Functions

Specs

new() :: t()

Default Elixir.Uptight.Text struct

Specs

new(binary()) :: t()
new(binary()) :: Uptight.Result.t()

Defensive constructor.

Examples

iex> Uptight.Text.new(<<5555>>) |> Uptight.Result.is_err?()
true

iex> Uptight.Text.new(<<322>>)
%Uptight.Result.Ok{ok: %Uptight.Text{text: "B"}}

iex> Uptight.Text.new(<<228>>) |> Uptight.Result.is_err?()
true

iex> Uptight.Text.new("hello") |> Uptight.Result.from_ok() |> Witchcraft.Foldable.right_fold("", fn x, acc -> x <> acc end)
"olleh"

Specs

new!(binary()) :: t()

Offensive constructor.

Specs

un(t()) :: binary()