This file contains 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've seen some examples of how JS promises fail Functor's composition law | |
// (by hijacking the `then` field of any JS object), making promises not valid | |
// functors (and by extension, unlawful monads), but I don't recall seeing a | |
// concise example of Promise breaking Monad's left identity law (though I'm | |
// sure this has been demonstrated somewhere before). | |
// | |
// The key here is that `return a` doesn't behave as expected when `a` is | |
// already a promise, due to the auto-collapsing nature of promises. | |
// Left Identity: |
This file contains 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 Face = { | |
[@deriving (enum, ord, eq)] | |
type t = | |
| Blank | |
| One | |
| Two | |
| Three | |
| Four | |
| Five | |
| Six |
This file contains 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 Measurement = { | |
type t = | |
| Tsp | |
| Tbsp | |
| Cup | |
| Ounce; | |
}; | |
module Ingredient = { | |
type t = {name: string}; |
This file contains 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 AudioDestinationNode = { | |
type t; | |
}; | |
module OscillatorNode = { | |
type t; | |
[@bs.send] | |
external connect: (t, AudioDestinationNode.t) => unit = "connect"; | |
}; |
This file contains 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 Main where | |
import Prelude | |
import Data.List (List(..), (:), fromFoldable, sortBy, reverse) | |
data Task = Task String Int | |
sortTasksByWeightDesc :: List Task -> List Task | |
sortTasksByWeightDesc = sortBy compareEffort >>> reverse where |
This file contains 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 = { |
This file contains 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 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 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 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 |
NewerOlder