commercialhaskell / commercialhaskell/jump

Interesting prelude design: Neon (from purescript)

Open
#13 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
155
Forks
4
PR merge metrics
No merged PRs in 30d

Description

Neon is a practical standard library for PureScript.

It has some unusual design principles.
It feels very coherent, pragmatic and productive.
I think it worth taking a look at it.
## Look and feel:

```
-- Find the sum of all the multiples of 3 or 5 below 1000.
--
import Neon
main :: Eff (console :: CONSOLE) Unit
main = 1
:upTo 999
:filter (divisibleBy 3 || divisibleBy 5)
:sum
:print
```

📝 `:` in neon is `&` in haskell
## Desing principles:

Here is a [~50 min video](https://www.youtube.com/watch?v=Jt3vDrKJzl8) where Neon author describe the architecture and respond to questions about his unusual design choices. (include interesting opinions on haskell naming, lenses, etc.)
- No partial functions
- Functions should take their subject last. This means add x y is really y + x. Consider calling functions with :, like y :add x.
- Everything should be documented with examples. Type signatures are not a substitute for documentation.
- Laws should not prohibit useful instances. This means you can use or on booleans and arrays. This also means you can do "ab" + "cd".
- There should be no type class hierarchy, only flat typeclasses. This means HasZero does not imply HasAdd. If you need both, add both to your type signature.
- There should be as few operators as possible. This means <$> does not exist. Use map instead.
- There should be one obvious way to do things. This means return is not an alias for pure. In fact, it doesn't exist at all.
- Functions should be defined in type classes. This means add can be used for both numbers and strings.
- Type classes should be as small as possible. This means the Bounded type class is split into HasBottom and HasTop.
- Type classes should be designed for programmers, not mathematicians. This means HasAdd is a semigroup, but it's not called Semigroup.
- Pure functions should not throw exceptions. This means fromInt returns a Maybe value. Pure functions that throw exceptions should be marked unsafe.
- Qualified imports are annoying, and fewer imports are better. This mean import Neon is enough. No need for tens of lines of imports.

---

Neon repository: https://github.com/tfausak/purescript-neon

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the linked purescript-neon repository and the linked ~50-minute design video; the issue names no jump files, tests, or entry points to inspect. There is no stated code change or completion criterion, so a maintainer would first need to define whether this should become documentation or another scoped task.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
documentation
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
15/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.