A representation of values in a toggleable UI as well as functions for
common transformations. The Toggleable type models values that are
independently toggleable. See it in action in this
live example.
If you are looking to implement "accordion"-style behavior, you may want to use a zipper implementation instead such as SelectList.
Toggle from Open to Closed or vice-versa.
toggle (Open "hello") -- Closed "hello"
toggle (Closed "hello") -- Open "hello"Convert a any toggleable value to Open.
open (Closed "hello") -- Open "hello"
open (Open "hello") -- Open "helloConvert a any toggleable value to Closed.
close (Closed "hello") -- Closed "hello"
close (Open "hello") -- Closed "helloGet the value inside the toggleable.
unwrap (Open "hello") -- "hello"Transform the value inside the toggleable without modifying the toggleable state.
map String.toUpper (Open "hello") -- Open "HELLO"
map String.toUpper (Closed "hello") -- Closed "HELLO"
Represent a value that might be toggled open or closed. You can put these directly in your model.