funcool / funcool/cats

Naming conventions

Open
#227 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Clojure
Stars
970
Forks
68
PR merge metrics
No merged PRs in 30d

Description

### How `def`/`defn`s should be named?

There are two pretty obvious choices: `file-path->*config-try-m` seems too "wordy".
But `file-name->*config` Is ambiguous since it doesn't specify the context - just says that there is one.

I ended up using [Orchestra](https://github.com/jeaye/orchestra) for exception monad:

``` clojure
(defmacro exception-of?
"Construct predicate function for testing exception monad value.
The predicate returns true if the monad contains `exc/failure`
or if `exc/success` wraps value satisfying PRED predicate."
[pred]
`(fn [*val#]
(and (exc/exception? *val#)
(if (exc/success? *val#)
(m/bind *val# ~pred)
true))))

(defn-spec file-name->*config (exception-of? valid-config?)
[f-name file?]
...)
```

It should be better than adding "type" info into doc-string since the return value is validated by Orchestra's `instrument` so it won't go stale.
And Emacs doc thingy displays definition un-expanded so it's immediately apparent what kind of context is used.

But mb it's an overkill. :thinking:

I haven't found any naming recommendation in [the docs](http://funcool.github.io/cats/latest/).

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.