{"id":17771328,"url":"https://github.com/lue-bird/elm-linear-direction","last_synced_at":"2025-08-13T03:15:13.567Z","repository":{"id":52681756,"uuid":"354897740","full_name":"lue-bird/elm-linear-direction","owner":"lue-bird","description":"up or down a structure","archived":false,"fork":false,"pushed_at":"2023-06-28T08:41:13.000Z","size":231,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-27T08:47:57.918Z","etag":null,"topics":["direction","elm"],"latest_commit_sha":null,"homepage":"https://package.elm-lang.org/packages/lue-bird/elm-linear-direction/latest/","language":"Elm","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lue-bird.png","metadata":{"files":{"readme":"README.md","changelog":"changes.md","contributing":"contributing.md","funding":null,"license":"LICENSE","code_of_conduct":"code_of_conduct.md","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":"2021-04-05T16:25:34.000Z","updated_at":"2022-04-11T13:02:38.000Z","dependencies_parsed_at":"2024-10-26T21:56:21.215Z","dependency_job_id":"53dc747d-8e3f-4e2a-982a-b1ce4e27dc73","html_url":"https://github.com/lue-bird/elm-linear-direction","commit_stats":{"total_commits":139,"total_committers":3,"mean_commits":"46.333333333333336","dds":"0.25899280575539574","last_synced_commit":"3f4f64c827efc68f51afc66b2e615020c4f0d684"},"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lue-bird%2Felm-linear-direction","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lue-bird%2Felm-linear-direction/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lue-bird%2Felm-linear-direction/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lue-bird%2Felm-linear-direction/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lue-bird","download_url":"https://codeload.github.com/lue-bird/elm-linear-direction/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246660077,"owners_count":20813338,"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":["direction","elm"],"created_at":"2024-10-26T21:31:43.532Z","updated_at":"2025-04-01T15:18:57.023Z","avatar_url":"https://github.com/lue-bird.png","language":"Elm","funding_links":[],"categories":[],"sub_categories":[],"readme":"## [linear direction](https://dark.elm.dmy.fr/packages/lue-bird/elm-linear-direction/latest/)\n\n  - `-r`/`-l`\n      - for example: `foldr`, `foldl`\n      - does `foldr` mean fold to the right? unclear and easy to mix up\n      - no `Array.getr/l`, `setr/l` but `foldr`, `foldl`?\n  - negative indices\n      - `Array.slice 0 -1` is handy! But you can't do `slice 2 -0`\n      - many operations support negative indices, but others don't\n      - not explicit → can have unintended side-effects\n\nHow about taking the **[`Direction`](Linear#Direction) as an argument**!\n\n```elm\nimport Linear exposing (Direction(..))\nimport List.Linear\nimport Array exposing (Array)\nimport Array.Linear\n\n[ 'l', 'i', 'v', 'e' ]\n    |\u003e List.Linear.foldFrom \"\" Up String.cons\n--\u003e \"evil\"\n\n[ 'l', 'i', 'v', 'e' ]\n    |\u003e List.Linear.foldFrom \"\" Down String.cons\n--\u003e \"live\"\n\nArray.fromList [ 'e', 'v', 'i', 'l' ]\n    |\u003e Array.Linear.element ( Down, 0 )\n--\u003e Just 'l'\n```\n\n  - → a less cluttered API, e.g.\n      - `foldFrom` instead of `foldr`, `foldl`\n      - `toChunksOf` instead of [`chunksFromLeft`/-`Right`](https://package.elm-lang.org/packages/elm-community/list-split/latest/List-Split)\n      - `padToAtLeast` instead of `resizerRepeat`, `resizelRepeat`, `resizerIndexed`, `resizelIndexed`\n\n  - → deal with both directions at once\n\n    ```elm\n    import Linear\n    import Array exposing (Array)\n    import Array.Linear\n\n    elementAlter :\n        ( Linear.Direction, Int )\n        -\u003e (element -\u003e element)\n        -\u003e (Array element -\u003e Array element)\n    elementAlter location alter =\n        \\array -\u003e\n            case array |\u003e Array.Linear.element location of\n                Nothing -\u003e\n                    array\n                    \n                Just elementAtLocation -\u003e\n                    array\n                        |\u003e Array.Linear.elementReplace location\n                            (\\() -\u003e elementAtLocation |\u003e alter)\n    ```\n\n  - → direction is always explicit\n\n## where `linear direction` is already being used\n\n  - [`emptiness-typed`](https://dark.elm.dmy.fr/packages/lue-bird/elm-emptiness-typed/latest/)\n  - [`typesafe-array`](https://dark.elm.dmy.fr/packages/lue-bird/elm-typesafe-array/latest/)\n  - [`keysset`](https://dark.elm.dmy.fr/packages/lue-bird/elm-keysset/latest/)\n  - [`rosetree-path`](https://dark.elm.dmy.fr/packages/lue-bird/elm-rosetree-path/latest/)\n\n## suggestions?\n\n→ [contribute](https://github.com/lue-bird/elm-linear-direction/blob/master/contributing.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flue-bird%2Felm-linear-direction","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flue-bird%2Felm-linear-direction","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flue-bird%2Felm-linear-direction/lists"}