{"id":15366625,"url":"https://github.com/turbomack/non-empty-list-alias","last_synced_at":"2025-09-10T02:32:56.753Z","repository":{"id":37748756,"uuid":"254960662","full_name":"turboMaCk/non-empty-list-alias","owner":"turboMaCk","description":"Functions for NonEmptyList you already have and Zipper implementation that goes with it.","archived":false,"fork":false,"pushed_at":"2023-08-16T16:12:10.000Z","size":79,"stargazers_count":7,"open_issues_count":1,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T20:11:46.421Z","etag":null,"topics":["comonad","database","elm","zipper"],"latest_commit_sha":null,"homepage":"https://package.elm-lang.org/packages/turboMaCk/non-empty-list-alias/latest/","language":"Elm","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/turboMaCk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-11T21:44:47.000Z","updated_at":"2023-07-25T14:34:42.000Z","dependencies_parsed_at":"2024-10-16T08:21:41.499Z","dependency_job_id":"794d7b97-b627-4fa1-a0e3-32118e1d7d39","html_url":"https://github.com/turboMaCk/non-empty-list-alias","commit_stats":{"total_commits":47,"total_committers":9,"mean_commits":5.222222222222222,"dds":0.276595744680851,"last_synced_commit":"743e4e2dc33895f151473c877800741431f7f94a"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/turboMaCk%2Fnon-empty-list-alias","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/turboMaCk%2Fnon-empty-list-alias/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/turboMaCk%2Fnon-empty-list-alias/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/turboMaCk%2Fnon-empty-list-alias/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/turboMaCk","download_url":"https://codeload.github.com/turboMaCk/non-empty-list-alias/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249071885,"owners_count":21208079,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["comonad","database","elm","zipper"],"created_at":"2024-10-01T13:19:19.906Z","updated_at":"2025-04-15T12:30:06.283Z","avatar_url":"https://github.com/turboMaCk.png","language":"Elm","funding_links":[],"categories":[],"sub_categories":[],"readme":"# List.NonEmpty alias with Zipper\n\n[![Build Status](https://travis-ci.org/turboMaCk/non-empty-list-alias.svg?branch=master)](https://travis-ci.org/turboMaCk/non-empty-list-alias)\n\nFunctions for `NonEmpty` list you already have and `Zipper` implementation that goes with it.\n\nImplementation of non-empty list defined as alias to pair `(a, List a)`.\nThis means that producing or consuming type compatible with this library doesn't require having it as a dependency.\nApart from this, this package aims to provide the most feature complete implementation of non-empty list for Elm and\nincludes variety of practical functions from JSON decoder helpers to hi-level combinators like `duplicate` and `extend`.\n\n## Motivation\n\n[elm/core](https://package.elm-lang.org/packages/elm/core/latest/) doesn't come with non empty list type.\nThis means one usually has to rely on library implementation of `NonEmpty` type:\n\n* [mgold/elm-nonempty-list](https://package.elm-lang.org/packages/mgold/elm-nonempty-list/latest/)\n* [hrldcpr/elm-cons](https://package.elm-lang.org/packages/hrldcpr/elm-cons/latest/)\n\nThese implementations usually define custom data type similar to `NonEmpty a = Cons a (List a)` and expose the constructor\nto make pattern matching possible. This makes it hard for library authors to provide\nsupport for `NonEmpty`, because they would need to pick one of these libraries and use it as a dependency\nof their own implementation and essentially impose this decision onto their users.\n\nThis library takes different approach. `NonEmpty` is an alias for the pair `type alias NonEmpty a = (a, List a)`.\nRelying on anonymous data-type like tuple means:\n\n1. [Libraries](https://package.elm-lang.org/packages/elm-community/list-extra/latest/List-Extra#uncons) can produce `NonEmpty` data without depending on specific (including this) implementation.\n1. Implementation provided by this package can be easily replaced by different implementation using the same type definition.\n1. Users may choose to work with tuple directly without need to transform from and to `NonEmpty` type.\n\n### Zipper\n\nOne of the downsides of common approach is also noticeable with available list zipper implementations.\n\n* [jjant/elm-comonad-zipper](https://package.elm-lang.org/packages/jjant/elm-comonad-zipper/latest/)\n* [wernerdegroot/listzipper](https://package.elm-lang.org/packages/wernerdegroot/listzipper/latest/)\n* [yotamDvir/elm-pivot](https://package.elm-lang.org/packages/yotamDvir/elm-pivot/latest/Pivot)\n\nAll of above are usually constructed using `List a -\u003e Maybe (Zipper a)` without possibility to construct zipper as `NonEmpty a -\u003e Zipper a`.\nThe motivation behind including `Zipper` in this package is to encourage its usage together with `NonEmpty` list.\nMy favorite implementation of list zipper which doesn't rely on `NonEmpty` is [zwilias/elm-holey-zipper](https://package.elm-lang.org/packages/zwilias/elm-holey-zipper/latest).\n\n### Drawbacks\n\nCompared to \"traditional\" implementations this implementation has less descriptive constructor in value space.\nThis means that pattern matching happens on the pair instead of explicit constructor like `Cons` or `NonEmpty`.\n\n**conventional library:**\n\n```elm\nmatchNonEmpty : NonEmptyList a -\u003e foo\nmatchNonEmpty (Cons h t) =\n    .....\n```\n\n**this library:**\n\n```elm\nmatchNonEmpty : NonEmptyList a -\u003e foo\nmatchNonEmpty (h, t) =\n    .....\n```\n\n## For Haskell Fanbois\n\n`List.NoneEmpty.NonEmpty` is:\n\n* Functor\n* Foldable\n* Applicative\n* Monad\n* Comonad\n\n`List.NonEmpty.Zipper` is:\n\n* Functor\n* Foldable\n* Applicative\n* Comonad\n\n`Maybe.NonEmpty` provides traversing functions between Maybes and `List.NonEmpty`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fturbomack%2Fnon-empty-list-alias","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fturbomack%2Fnon-empty-list-alias","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fturbomack%2Fnon-empty-list-alias/lists"}