Skip to content
This repository has been archived by the owner on Feb 26, 2022. It is now read-only.

axelo/elmish-core-ts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DEPRECATED

To be useful, this should be part of the language itself. A library/framework will never be able to achieve the same thing consistently.

elmish-core-ts

A library for writing more functional the Elm way with your TypeScript.

Examples

pipe

import { pipe } from "elmish-core-ts";

const addOne = (val: number) => val + 1;
const addWith = (withWhat: number) => (val: number) => val + withWhat;
const toString = (val: number): string => String(val);
const appendWith = (withWhat: string) => (val: string) => val + withWhat;

console.log(
  pipe(
    addOne(0), // 0 + 1
    addWith(5), // 1 + 5
    toString, // "6"
    appendWith("!") // "6!"
  )
); // 6!

Maybe

import { Just, Maybe, Nothing, pipe } from "elmish-core-ts";

console.log(Maybe.withDefault("1970-01-01")(Just("1999-12-31"))); // 1999-12-31

console.log(Maybe.withDefault("1970-01-01")(Nothing)); // 1970-01-01

console.log(
  pipe(
    Just("1999-12-31"),
    Maybe.withDefault("1970-01-01")
  )
); // 1999-12-31

console.log(
  pipe(
    Nothing,
    Maybe.withDefault("1970-01-01")
  )
); // 1970-12-31

Realworld examples

About

Write more functional the Elm way with your TypeScript

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published