Editable represents a value that can be read-only or editable.
ReadOnly a holds the locked value and Editable a a holds both the old and the newly modified value.
Cancels a modified value. This puts the old value into the context of ReadOnly.
Editable.Editable "old" "new"
|> Editable.cancel --> ReadOnly "old"Makes a ReadOnly value Editable.
Editable.ReadOnly "old"
|> Editable.edit
|> Editable.map (always "new") --> Editable "old" "new"Indicates if a modified value has changed from the saved one, by checking equality of both values.
If the Editable is ReadOnly then we return False.
Editable.Editable "old" "old"
|> Editable.isDirty --> False
Editable.Editable "old" "new"
|> Editable.isDirty --> True
Editable.ReadOnly "old"
|> Editable.isDirty --> FalseIndicates if a modified value has changed from the saved one, by a provided function.
If the Editable is ReadOnly then we return False.
Editable.Editable "old" "old"
|> Editable.isDirtyWith (/=) --> False
Editable.Editable "old" "new"
|> Editable.isDirtyWith (/=) --> True
Editable.ReadOnly "old"
|> Editable.isDirtyWith (/=) --> FalseIndicates if an Editable is in Editable state.
Editable.Editable "old" "old"
|> Editable.isEditable --> True
Editable.ReadOnly "old"
|> Editable.isEditable --> FalseIndicates if an Editable is in ReadOnly state.
Editable.Editable "old" "old"
|> Editable.isReadOnly --> False
Editable.ReadOnly "old"
|> Editable.isReadOnly --> TrueApply a function to an Editable. This is the function you will call in
order to update the value of an Editable.Editable.
Editable.ReadOnly "old"
|> Editable.map String.toUpper --> ReadOnly "old"
Editable.Editable "old" "old"
|> Editable.map String.toUpper --> Editable "old" "OLD"
Editable.Editable "old" "new"
|> Editable.map (\val -> val ++ "er") --> Editable "old" "newer"
Editable.Editable "old" "old"
|> Editable.map (always "new") --> Editable "old" "new"Save a modified value. This puts the modified value into the context of ReadOnly.
Editable.Editable "old" "new"
|> Editable.save --> ReadOnly "new"
Editable.ReadOnly "old"
|> Editable.edit
|> Editable.map (always "new")
|> Editable.save --> ReadOnly "new"Returns the current value of an Editable.
Editable.ReadOnly "old"
|> Editable.value --> "old"
Editable.Editable "old" "new"
|> Editable.value --> "new"
An
Editablevalue is eitherReadOnlyorEditable.