practicalli / practicalli/clojure

Threading macros - an idiom for applying them

Open
#71 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Makefile
Stars
117
Forks
36
PR merge metrics
No merged PRs in 30d

Description

Idiom for general use

-> for collection functions
->> for sequence functions

Sequence functions accept a sequence as the last argument of the function call, so thread with ->>

Collection functions accept the collection as the first argument, so thread with ->

Nesting threading macros - usually avoid

->> and as-> can be nested inside ->
but you can't nested those inside ->> so if you ever need a "mixed" pipeline, start with ->:

(-> data
    (->> (map my-function)
         (filter my-predicate)
         (reduce reducing-function initial-value))
    (as-> value (do stuff to value with args))
    (process with some args))

Mixed pipeline should generally be avoided as it indicates the value is "changing shape". The above would be better broken into smaller pieces, eg. with a let expression.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No documentation file or test is named in the issue. Start by locating the project's documentation on Clojure threading macros, then add the idiom and nesting guidance from the issue; done means the guidance is included in the appropriate documentation location and renders correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
clojure
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.