Skip to content

Instantly share code, notes, and snippets.

View juanbono's full-sized avatar
:shipit:

Juan Bono juanbono

:shipit:
View GitHub Profile
@juanbono
juanbono / gist:5f09876c3393ca801fce69e4a9db7c3b
Created December 2, 2019 23:19 — forked from lukego/gist:3952159
Erlang literate programming
Simple literate programming.
Add comments to your Erlang file with a special %%% syntax, like this:
%%% This is a comment that will be formatted in a variable width font with Markdown.
%%% You can use *emphasis* and
%%% # Headings
%%% and even
%%%
%%% - Lists
@juanbono
juanbono / stlc.prolog
Created October 23, 2019 12:19 — forked from kayceesrk/stlc.prolog
Type inference and program synthesis from simply typed lambda calculus type checking rules
?- set_prolog_flag(occurs_check,true).
lookup([(X,A)|_],X,A).
lookup([(Y,_)|T],X,A) :- \+ X = Y, lookup(T,X,A).
/* Rules from the STLC lecture */
pred(D,DD) :- D >= 0, DD is D - 1.
type(_,u,unit,D) :- pred(D,_).
@juanbono
juanbono / sql_parser.exs
Created October 13, 2019 13:51 — forked from sasa1977/sql_parser.exs
Basic SQL parser developed at WebCamp Zagreb, 2019
defmodule SqlParser do
def run() do
input = "select col1 from (
select col2, col3 from (
select col4, col5, col6 from some_table
)
)
"
IO.puts("input: #{inspect(input)}\n")
IO.inspect(parse(input))
@juanbono
juanbono / RegAlloc1.hs
Created April 18, 2019 20:12 — forked from thoughtpolice/RegAlloc1.hs
Simple register allocation, see "Essentials of Compilation" for more https://jeapostrophe.github.io/courses/2017/spring/406/notes/book.pdf
{-# OPTIONS_GHC -Wall #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PartialTypeSignatures #-}
module RegAlloc1
( -- * Types
Var
@juanbono
juanbono / steps.txt
Created April 10, 2018 00:11 — forked from softprops/steps.txt
Steps to build an awesome ecosystem
1. have a brilliant idea for something you want to use
2. Stop! Don't start building it.
3. Find a project that does something similar. (This likely exists)
4. Read it's documentation.
* If it has none, learn the project and create some.
* If it does, try to build something with it and document what wasn't clear.
5. If it feels broke. Write some failing tests,
* If possible, fix them, then open a pr
* If not, open a pr with failing tests and get the maintainer to teach you how to fix them
6. Document your process for contributing in a file called CONTIBUTING.md
@juanbono
juanbono / thinkingInReact.re
Created February 11, 2018 14:22 — forked from broerjuang/thinkingInReact.re
This is the implementation of thinking in react using reason
type product = {
category: string,
price: string,
stocked: bool,
name: string
};
type products = list(product);
let products = [
type copyOpts;
[@bs.obj] external makeCopyOpts : (~overwrite: bool=?, ~errorOnExist: bool=?, ~dereference: bool=?, ~preserveTimestamps: bool=?, ~filter: (string=>bool)=?, unit) => copyOpts = "";
/* copySync(src, dest, [options]) */
/* https://github.com/jprichardson/node-fs-extra/blob/master/docs/copy-sync.md */
[@bs.module "fs-extra"] external copySyncExternal : (string, string, copyOpts) => unit = "copySync";
let copySync = (~overwrite=?, ~errorOnExist=?, ~dereference=?, ~preserveTimestamps=?, ~filter:option(string => bool)=?,
src: string, dest: string) =>
@juanbono
juanbono / Preorders.agda
Created January 19, 2018 17:17 — forked from rntz/Preorders.agda
Some simple order/category theory
{-# OPTIONS --postfix-projections #-}
module Preorders where
open import Level
open import Data.Unit hiding (_≤_)
open import Data.Product hiding (map)
open import Function hiding (id)
open import Relation.Binary public using (Reflexive; Transitive; Symmetric; _=[_]⇒_)
import Relation.Binary.PropositionalEquality as Eq
open Eq using (_≡_)
@juanbono
juanbono / CBNLambdaEff.hs
Created January 12, 2018 22:09 — forked from dorchard/CBNLambdaEff.hs
A Haskell implementation of the categorical semantics for the effectful CBN lambda calculus
{-# LANGUAGE GADTs, TypeFamilies, EmptyDataDecls #-}
{-
A Haskell-based implementation of the monadic semantics for the
simply-typed Call-By-Name computational lambda calculus, following
Moggi's 'Computational lambda-calculus and monads' (1989) (technical report version)
but for the typed calculus (rather than untyped as in this paper).
Category theory seminar, Programming Languages and Systems group,