This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// I'm not entirely sure what this thing is. It feels powerful and expressive | |
// and like you can compose things. Not sure what it would be useful for, though. | |
// Maybe you could make a UI to build arbitrarily complex predicate functions | |
// for filtering collections of data? | |
module RuleEngine = { | |
type t('a) = | |
| Rule('a) | |
| Not(t('a)) | |
| And(t('a), t('a)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[%do Future] | |
do { | |
user <- getUser("some_user_id") | |
orders = user.orders | |
firstOrderId <- orders |> List.head |> Future.fromOption | |
order <- getOrder(firstOrderId) | |
pure(user.firstName ++ " ordered a " ++ order.productName) | |
}; | |
Future.( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let onClick = _ => send(ToggleMenu); | |
// The following is how elm-ui does it (translated to JSX) | |
// Pros: | |
// - Relatively easy to understand | |
// - `Button` is any normal component | |
// - It's obvious that the container element can have all of the normal | |
// layout props and decoration attributes | |
// | |
// Cons: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open Typeclasses; | |
// a binary search tree is a binary tree that holds order-able members and | |
// keeps lesser values on the left and greater or equal values on the right | |
module Make = (Order: Ord) => { | |
type t = | |
| Empty | |
| Node(t, Order.t, t); | |
// O(log n) operation to add a new value in a valid position in the tree |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let (<|) = ('a => 'b, 'a) => 'b; // purescript and haskell use ($) | |
let (|>) = ('a, 'a => 'b) => 'b; // purescript uses (#) | |
let compose: ('b => 'c, 'a => 'b, 'a) => 'c; | |
let (<<) = compose; // purescript uses (<<<), haskell uses (.) | |
let composeFlipped: ('a => 'b, 'b => 'c, 'a) => 'c; | |
let (>>) = composeFlipped; // purescript uses (>>>) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module type Monad = | |
sig | |
type 'a t | |
val map : ('a -> 'b) -> 'a t -> 'b t | |
val apply : ('a -> 'b) t -> 'a t -> 'b t | |
val pure : 'a -> 'a t | |
val bind : 'a t -> ('a -> 'b t) -> 'b t | |
end | |
module Option : Monad with type 'a t = 'a option = struct |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open Relude.Globals; | |
let baseUrl = "http://localhost:5050"; | |
// `getForecast` is an IO that will either succeed with decoded | |
// ForecastData or fail with a Fetch error. | |
// | |
// Since IO is inherently lazy, creating this value doesn't actually | |
// _do_ anything. Instead it needs to be run, which we do inside an | |
// `UpdateWithIO` return from a `useReducer` branch in our view. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE | |
'use strict'; | |
var ReludeRandom_Seed = require("./ReludeRandom_Seed.bs.js"); | |
var ReludeRandom_Generator = require("./ReludeRandom_Generator.bs.js"); | |
var ReludeRandom_RandomInt = require("./ReludeRandom_RandomInt.bs.js"); | |
var ReludeRandom_RandomList = require("./ReludeRandom_RandomList.bs.js"); | |
var Seed = { | |
fromInt: ReludeRandom_Seed.fromInt, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE | |
'use strict'; | |
var List$Modules = require("./List.bs.js"); | |
var String$Modules = require("./String.bs.js"); | |
var x = List$Modules.contains(String$Modules.Eq, "a", /* :: */[ | |
"b", | |
/* :: */[ | |
"c", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let const = (a, _) => a; | |
let (<<) = (f, g, a) => f(g(a)); | |
module type Type = {type t;}; | |
module Function1 = { | |
type t('input, 'output) = 'input => 'output; | |
}; | |
module type Functor = { |