jsuder-xx/elm-ra/1.1.0

NOTE: the latest version is 1.1.1

elm-ra

Ra supports Pointfree style in Elm by providing various combinators to work with Predicates, Relations, Math, Functions, and Flow Control.

Pointfree can be abused, but when it is appropriate pointfree style is

  • More Readable & Literate. The declaration of the lambda with an argument and repetitious application of the argument can obscure the meaning.
  • Safer. It is impossible to inadvertently pass the wrong value because functions are only composed and not applied or called.

Categories

  • Predicate Combinators: allPass, anyPass, both, either, complement, false, true
  • Chain and Composition Friendly Relations: lessThan, lessThanEqualTo, greaterThan, greaterThanEqualTo, equals
  • Chain and Composition Friendly Math: adding, subtracting, dividedByInt, dividedByFloat, multiplying, negated
  • Flow Control: ifElse, cond, condDefault, when, unless, until
  • Function Combinators: converge, converge3, convergeList, curry, curry3, flip, fnContraMap, fnContraMap2, fnContraMap3, uncurry, uncurry3

Name and Relation to RamdaJS

Ra is a subset of RamdaJS converted to Elm and excluding functions relating to topics indicated below.

Excellent elm-community Extra packages such as

Many of the RamdaJS functions or their equivalent functionality can be found in these packages.

Object Meta-Programming

RamdaJS features a number of functions to manipulate JavaScript objects. The closest equivalent in Elm would be Dict which already features all of the necessary functions either through Core or Dict.Extra. Further, Dict is not the same as Record and has a number of tradeoffs when compared to Records

  • Loss of explicit type contract
    • Requiring neurotic optionality checks (i.e. Dict.get returns a Maybe)
  • A Dict can only hold values of a single type while a Record may feature a different type for each field.

Relating to Optics (Lens)

There are several high quality Elm packages that provide optics.

Higher-Kinded Types and Categories

Elm does not feature higher kinded types or typeclasses and so we cannot express abstract

  • map (Functor)
  • chain (Monad)
  • append (Monoid)
  • sequence/traverse (Applicative, Traversable).

NOTE We get better error messages, fewer opportunities for ambiguous code, and, very likely, a faster compiler in the exchange.