All Projects → JoelQ → elm-javascript-haskell-equivalents

JoelQ / elm-javascript-haskell-equivalents

Licence: other
Comparison of similar functions across Elm, Javascript, and Haskell

Projects that are alternatives of or similar to elm-javascript-haskell-equivalents

Es6
ES5 vs ES6 Reference
Stars: ✭ 158 (+409.68%)
Mutual labels:  syntax, comparison
elixir-sublime-syntax
The most powerful Elixir for the most Sublime experience.
Stars: ✭ 28 (-9.68%)
Mutual labels:  syntax
PHPench
Realtime benchmarks for PHP code
Stars: ✭ 53 (+70.97%)
Mutual labels:  comparison
language-rust
Parser and pretty-printer for the Rust language
Stars: ✭ 78 (+151.61%)
Mutual labels:  syntax
cheatsheet-python-A4
📖 Advanced Python Syntax In A4
Stars: ✭ 96 (+209.68%)
Mutual labels:  syntax
language-rainmeter
Syntax highlighting for Rainmeter files in Atom.
Stars: ✭ 19 (-38.71%)
Mutual labels:  syntax
PowerShell-Watch
A PowerShell Watch-Command cmdlet for repeatedly running a command or block of code until a change in the output occurs.
Stars: ✭ 49 (+58.06%)
Mutual labels:  comparison
octoclairvoyant-webapp
Compare GitHub changelogs across multiple releases in a single view.
Stars: ✭ 45 (+45.16%)
Mutual labels:  comparison
won
A new way to see HTML Web Pages
Stars: ✭ 15 (-51.61%)
Mutual labels:  comparison
frameworks-code-comparison
🆚 🔥 Code comparison of modern web frameworks, based on React, Angular and Vue.js
Stars: ✭ 87 (+180.65%)
Mutual labels:  comparison
nord-atom-syntax
An arctic, north-bluish clean and elegant Atom syntax theme.
Stars: ✭ 72 (+132.26%)
Mutual labels:  syntax
syntax highlighter
Syntax Highlighter for Dart/Flutter Code
Stars: ✭ 28 (-9.68%)
Mutual labels:  syntax
reactive-states
Reactive state implementations (brainstorming)
Stars: ✭ 51 (+64.52%)
Mutual labels:  comparison
nord-notepadplusplus
An arctic, north-bluish clean and elegant Notepad++ theme.
Stars: ✭ 112 (+261.29%)
Mutual labels:  syntax
speech-recognition-evaluation
Evaluate results from ASR/Speech-to-Text quickly
Stars: ✭ 25 (-19.35%)
Mutual labels:  comparison
colocat
Fegeya Colocat, Colorized 'cat' implementation. Written in C++17.
Stars: ✭ 14 (-54.84%)
Mutual labels:  syntax
calamity-atom
A purple dark theme with medium to high contrast for the Atom editor ⚛️
Stars: ✭ 12 (-61.29%)
Mutual labels:  syntax
c-compiler-frontend
💻NUAA 2017 编译原理 - C(缩减)语言编译器前端 - Python
Stars: ✭ 44 (+41.94%)
Mutual labels:  syntax
xdem
Analysis of digital elevation models (DEMs)
Stars: ✭ 50 (+61.29%)
Mutual labels:  comparison
json-path-comparison
Comparison of the different implementations of JSONPath and language agnostic test suite.
Stars: ✭ 64 (+106.45%)
Mutual labels:  comparison

Functional Syntax in JS, Elm, and Haskell

Elm developers often come from one of two opposite directions.

  1. JavaScript programmers who know front-end web dev but want to introduce typed FP
  2. Haskell programmers who know typed FP but want to use it for front-end web dev

This leads to lots of comparisons of Elm functions to similar ones in both JavaScript and Haskell. Now you can have all of them in one place.

Collections

Collection data structures are core to most of programming. Here's how the various collections in Elm compare to equivalents in JavaScript and Haskell.

Purpose JavaScript Elm Haskell
Random access via key - dynamic keys Map Dict Map
Random access via key - static keys N/A records records
Unique values Set Set Set
Preserve order, random access via index Array Array Array
Preserve order, no random access N/A List List

List transformations

The default collection in Elm is the list. This is a breakdown of some of the more common functional list operations.

Purpose JavaScript Elm Haskell
Combine all elements into a new value Array.prototype.reduce List.foldl foldl
Apply a function to each element Array.prototype.map List.map fmap
Only keep elements that match Array.prototype.filter List.filter filter
Get the first item array[0] List.head head
Get the first element that matches Array.prototype.find N/A find

Other Common Data Structures

Purpose JavaScript Elm Haskell
Optional values null Maybe Maybe
Error handling try / catch Result Either
Async work Promise Task IO
Side effects N/A Task / Cmd IO

Operators

Haskell is notorious for its use of operators. Here's how Elm concepts line up with some of the most common Haskell operators. Most of these FP operations don't exist in JavaScript (yet).

For more details on the Haskell operators, check out this guide.

Description JavaScript Elm Haskell
Forwards pipe |> (experimental) |> &
Backwards pipe <| $
Mapping various map functions <$>
Applying various (third party) andMap functions <*>
Chaining various andThen and concatMap functions >>=
Appending + ++ <>
Backwards composition << .
Forwards composition >>
Alternative various (third party) or functions <|>

Convenience functions

Purpose JavaScript Elm Haskell
return the argument N/A identity id
ignore the second argument N/A always const
flip the arguments of a function N/A flip flip
treat two-tuple as two args N/A curry curry
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].