Skip to content

Instantly share code, notes, and snippets.

View piq9117's full-sized avatar
๐Ÿ’€
Nothing good is happening here

piq9117 piq9117

๐Ÿ’€
Nothing good is happening here
View GitHub Profile
let explode s =
let rec expl i l =
if i < 0 then l else
expl (i - 1) (s.[i] :: l) in
expl (String.length s - 1) []
let implode l =
let result = Bytes.create (List.length l) in
let rec imp i = function
| [] -> result
open BsWebapi.Webapi.Dom
module Error = struct type 'e t = 'e Js.t end
module Database =
struct
type t
module rec
Reference:sig
type t
external key : t -> string Js.nullable = ""[@@bs.get ]
external parent : t -> t Js.nullable = ""[@@bs.get ]
@piq9117
piq9117 / PhantomTypeReasonML.md
Created November 8, 2018 03:19 — forked from busypeoples/PhantomTypeReasonML.md
Phantom types in ReasonML

Phantom types in ReasonML

Introduction

"A phantom type is a parametrised type whose parameters do not all appear on the right-hand side of its definition..." Haskell Wiki, PhantomType

The following write-up is intended as an introduction into using phantom types in ReasonML.

Taking a look at the above definition from the Haskell wiki, it states that phantom types are parametrised types where not all parameters appear on the right-hand side. Let's try to see if we can implement a similar example as in said wiki.

@piq9117
piq9117 / Monad.ml
Created November 5, 2018 23:07 — forked from nvanderw/Monad.ml
IO Monad in OCaml
module type FUNCTOR = sig
type 'v f
val map : ('a -> 'b) -> 'a f -> 'b f
end
module type MONAD = sig
type 'v f
val map : ('a -> 'b) -> 'a f -> 'b f
val pure : 'a -> 'a f
val join : ('a f) f -> 'a f
@piq9117
piq9117 / Monad.ml
Created November 5, 2018 23:07 — forked from nvanderw/Monad.ml
IO Monad in OCaml
module type FUNCTOR = sig
type 'v f
val map : ('a -> 'b) -> 'a f -> 'b f
end
module type MONAD = sig
type 'v f
val map : ('a -> 'b) -> 'a f -> 'b f
val pure : 'a -> 'a f
val join : ('a f) f -> 'a f
#!/bin/sh
rm -rf lib/bs/mli
mkdir -p lib/bs/mli
filepath(){
FILENAME=`echo $(basename $1) | cut -d'-' -f 1`
echo "lib/bs/mli/$FILENAME.mli"
}
@piq9117
piq9117 / nativeJavaScript.js
Created September 28, 2018 20:20 — forked from alexhawkins/nativeJavaScript.js
Implementation of Native JavaScript Methods (forEach, Map, Filter, Reduce, Every, Some)
'use strict';
/*****************NATIVE forEACH*********************/
Array.prototype.myEach = function(callback) {
for (var i = 0; i < this.length; i++)
callback(this[i], i, this);
};
//tests
@piq9117
piq9117 / monad-comprehension.ts
Last active September 27, 2018 14:46
Monad comprehension using generators
const run = (iter, val = null) => ({
const next = iter.next(val);
if (!next.done) {
next.value.then(result => run(iter, result));
}
});
run(function*() {
const a = yield fs.readFile("a.txt");
const b = yield fs.readFile("b.txt");
@piq9117
piq9117 / IosevkaConfigGen.hs
Created September 16, 2018 22:06 — forked from mrkgnao/IosevkaConfigGen.hs
Render Iosevka ligatures to Private Use Area glyphs, for Emacs
{-# LANGUAGE RecordWildCards, Arrows #-}
import Numeric
import Data.Char
import Control.Monad
import Data.Monoid ((<>))
import Data.List (nub, sort, reverse)
data RepeatBounds = RB
stack exec -- ghcid -c "stack ghci [project_name]"