All Projects → benji6 → Church

benji6 / Church

Licence: mit
⛪️ Church Encoding in JS

Programming Languages

javascript
184084 projects - #8 most used programming language
haskell
3896 projects

Projects that are alternatives of or similar to Church

Combinators Js
🐦 Some combinators
Stars: ✭ 114 (+6.54%)
Mutual labels:  lambda-calculus, functional-programming
Curryhoward
Automatic code generation for Scala functions and expressions via the Curry-Howard isomorphism
Stars: ✭ 229 (+114.02%)
Mutual labels:  lambda-calculus, functional-programming
Y Combinator For Non Programmers
🍱 Y Combinator for Non-programmers: A Wild Introduction to Computer Science
Stars: ✭ 109 (+1.87%)
Mutual labels:  lambda-calculus, functional-programming
Write You A Haskell
Building a modern functional compiler from first principles. (http://dev.stephendiehl.com/fun/)
Stars: ✭ 3,064 (+2763.55%)
Mutual labels:  lambda-calculus, functional-programming
Magic In Ten Mins
十分钟魔法练习
Stars: ✭ 327 (+205.61%)
Mutual labels:  lambda-calculus, functional-programming
Fp Core.rs
A library for functional programming in Rust
Stars: ✭ 772 (+621.5%)
Mutual labels:  lambda-calculus, functional-programming
Kind
A modern proof language
Stars: ✭ 2,075 (+1839.25%)
Mutual labels:  lambda-calculus, functional-programming
Lambda
🔮 Estudos obscuros de programação funcional
Stars: ✭ 297 (+177.57%)
Mutual labels:  lambda-calculus, functional-programming
Lambda Talk
A Flock of Functions: Combinators, Lambda Calculus, & Church Encodings in JS
Stars: ✭ 315 (+194.39%)
Mutual labels:  lambda-calculus, functional-programming
Plam
An interpreter for learning and exploring pure λ-calculus
Stars: ✭ 385 (+259.81%)
Mutual labels:  lambda-calculus, functional-programming
Lambda
Fun with λ calculus!
Stars: ✭ 65 (-39.25%)
Mutual labels:  lambda-calculus, functional-programming
Faux Pas
A library that simplifies error handling for Functional Programming in Java
Stars: ✭ 100 (-6.54%)
Mutual labels:  functional-programming
Articles
Code snippets for articles posted at 4comprehension.com
Stars: ✭ 96 (-10.28%)
Mutual labels:  functional-programming
Sspipe
Simple Smart Pipe: python productivity-tool for rapid data manipulation
Stars: ✭ 96 (-10.28%)
Mutual labels:  functional-programming
Scalacaster
Purely Functional Algorithms and Data Structures in Scala
Stars: ✭ 1,342 (+1154.21%)
Mutual labels:  functional-programming
Parapet
A purely functional library to build distributed and event-driven systems
Stars: ✭ 106 (-0.93%)
Mutual labels:  functional-programming
Java8 Guides Tutorials
Java 8 Guides and Tutorials - A lot of awesome examples using Java 8 features like Stream, Lambda, Functional Interface, Date and Time API and much more
Stars: ✭ 100 (-6.54%)
Mutual labels:  functional-programming
Tetris
A clone of the popular game Tetris.
Stars: ✭ 96 (-10.28%)
Mutual labels:  functional-programming
Tensor Safe
A Haskell framework to define valid deep learning models and export them to other frameworks like TensorFlow JS or Keras.
Stars: ✭ 96 (-10.28%)
Mutual labels:  functional-programming
Paperplane
Lighter-than-air node.js server framework
Stars: ✭ 95 (-11.21%)
Mutual labels:  functional-programming

church

npm version CI

Church encoding utility library for JavaScript

Why?

I built this library mostly as a learning exercise, but the code is also available as an npm module that can be consumed and used to build JavaScript applications using basically nothing but functions. I'm not sure why you would want to do that though!

What?

Church encoding is a way of encoding data using only functions. For instance, we can use functions to represent, booleans, numerals and lists. Higher-order functions are all you need for Turing completeness.

How?

Check out the docs.

Install

npm i church or yarn add church.

Examples

import {
  decodeList,
  decodeNumeral,
  encodeList,
  encodeNumeral,
  five,
  If,
  lt,
  map,
  mult,
  one,
  range,
  three,
  two,
} from 'church'

const twoFourSix = map(mult(two))(range(one)(three))
// => Church encoded list of [two four six]

const twoFourSixJs = decodeList(twoFourSix).map(decodeNumeral)
// => [2, 4, 6] (standard JS array of standard JS numbers)

encodeList(twoFourSixJs.map(encodeNumeral))
// => Church encoded list of [two four six] again

map(x => If(lt(x)(five))(five)(x))(twoFourSix)
// => Church encoded list of [five five six]

Resources

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].