aria2c \
-x 16 \
-s 16 \
--load-cookies=cookies.txt \
https://download.developer.apple.com/Developer_Tools/Xcode_10.3/Xcode_10.3.xip
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 (<|) = ('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 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
// This is a proper alternative to | |
// https://github.com/BuckleScript/bucklescript/blob/b9508105b1a35537bdea9a1fabd10f6c65f776b4/jscomp/bsb/templates/react-hooks/src/FetchedDogPictures/FetchedDogPictures.re#L14 | |
// The one in that file uses Promise, but that's *wrong*. | |
// We only used promise as a demo of its API. We'll remove it soon. | |
// As you can see below, the pure XMLHttpRequest code is just as clean, | |
// less mysterious for all, more performant, extensible, and actually correct. | |
// Ignore these externals for now. They're just for illustration | |
// purposes. I just copy pasted the Js code from |
Packaging JavaScript applications can be a bit overwhelming. The popular project uglifyjs does not support ES6, it is cumbersome to configure the allmighty Webpack, bundlers like Parcel and Microbundle still have bugs or do not compile to ESM bundles that work in a browser. It is hard to figure out the best way to bundle an application.
Here I give a small example, how we achieve the goal using the
- TypeScript compiler
- rollup.js bundler
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 Belt; | |
type t(+'a) = Js.Promise.t('a); | |
type error = Js.Promise.error; | |
type result('ok, 'error) = t(Result.t('ok, 'error)); | |
external errorToString: error => string = "%identity"; | |
[@bs.new] |
- Go to https://reasonml.github.io/reason-react/ and follow the QuickStart instructions (you don't need to run
npm run webpack
) - Open another shell and run
npm run server
to start a webserver displaying your site - visit localhost:8000 to see the site. - Run
npm install reason-urql
. This will let you make graphql queries using react hooks. - Run
npm install graphql_ppx
. This will let you construct your graphql queries safely and easily. - Open bsconfig.json and add
reason-urql
to your"bs-dependencies"
list (reason-react
should already be there). - Also add
"ppx-flags": ["graphql_ppx/ppx"]
. - Run
npx send-introspection-query http://cc265406.ngrok.io/graphql
. - Check out the examples in the
reason-urql
to see how to use the hooks. Example query and hook. - The graphql server is at `http://cc
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 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 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 Core | |
let rec list_set_exn index v = function | |
| [] -> [] | |
| _ :: xs when index = 0 -> v :: xs | |
| x :: xs -> x :: list_set_exn (Int.pred index) v xs |
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 whitespaceRegex = Js.Re.fromString("\\s+"); | |
/** | |
* This is a little helper to make sure that classNames are BEM style | |
* | |
* Example: | |
* module B = | |
* BEM.Block({ | |
* let block = "Legal"; | |
* }); |