Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lue-bird/elm-emptiness-typed
one type for emptiable and safe non-empty
https://github.com/lue-bird/elm-emptiness-typed
elm focus non-empty pivot scroll select-list type-safety ziplist
Last synced: 4 months ago
JSON representation
one type for emptiable and safe non-empty
- Host: GitHub
- URL: https://github.com/lue-bird/elm-emptiness-typed
- Owner: lue-bird
- License: mit
- Fork: true (zwilias/elm-holey-zipper)
- Created: 2021-11-14T11:03:20.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2023-05-23T23:45:34.000Z (over 1 year ago)
- Last Synced: 2023-08-08T20:39:34.994Z (over 1 year ago)
- Topics: elm, focus, non-empty, pivot, scroll, select-list, type-safety, ziplist
- Language: Elm
- Homepage: https://package.elm-lang.org/packages/lue-bird/elm-emptiness-typed/latest/
- Size: 3.12 MB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: changes.md
- Contributing: contributing.md
- License: LICENSE
Awesome Lists containing this project
README
> one type for emptiable and safe non-empty
# [emptiness typed](https://package.elm-lang.org/packages/lue-bird/elm-emptiness-typed/latest/)
**_🧩 Read about [allowable state](https://package.elm-lang.org/packages/lue-bird/elm-allowable-state/latest/) first_**
## [📦 `Emptiable`](Emptiable) `..... Never |` [`Possibly`](https://dark.elm.dmy.fr/packages/lue-bird/elm-allowable-state/latest/Possibly)
A `Maybe` value that can be made non-empty depending on what we know – an "emptiable-able" value
```elm
import Emptiable exposing (Emptiable, filled, fill)type alias TextFilled =
{ first : Char, afterFirst : String }first : Emptiable TextFilled Never -> Char
first =
fill >> .firstmaybeFirst :
Emptiable TextFilled possiblyOrNever
-> Emptiable Char possiblyOrNever
maybeFirst =
Emptiable.map (filled >> first)
```## [📚 `Stack`](Stack)
Handle lists that are
[`Possibly`](https://dark.elm.dmy.fr/packages/lue-bird/elm-allowable-state/latest/Possibly)
or `Never` [`Emptiable`](Emptiable#Emptiable)
in one go`Emptiable ... Never` allows safe `Maybe`-free
[`top`](Stack#top), [`removeTop`](Stack#removeTop),
[`fold`](Stack#fold) (for finding the maximum etc.; some call it "fold1"), ...That's more useful than you might think.
```elm
import Linear exposing (Direction(..))
import Emptiable exposing (Emptiable)
import Stack exposing (Stacked)Emptiable.empty
--: Emptiable (Stacked element_) Possibly
|> Stack.onTopLay 0
--: Emptiable (Stacked number_) never_
|> Stack.attach Down (Stack.topBelow 1 [ 2, 3 ])
--: Emptiable (Stacked number_) never_
|> Stack.toTopBelow
--> ( 1, [ 2, 3, 0 ] )
```## where `emptiness-typed` is already being used
- [🗃️ `elm-keysSet`](https://dark.elm.dmy.fr/packages/lue-bird/elm-keysset/latest/)
- [📜 `elm-scroll`](https://dark.elm.dmy.fr/packages/lue-bird/elm-scroll/latest/)
- [🚥 `typesafe-array`](https://dark.elm.dmy.fr/packages/lue-bird/elm-typesafe-array/latest/)## suggestions?
→ See [contributing.md](https://github.com/lue-bird/elm-emptiness-typed/blob/master/contributing.md)