Skip to content

Instantly share code, notes, and snippets.

View romac's full-sized avatar
🔮
λ

Romain Ruetschi romac

🔮
λ
View GitHub Profile
@romac
romac / LambdaCoproduct.hs
Last active May 18, 2017 09:22
An experiment with modeling a nanopass compiler with coproducts and recursion-schemes, inspired by https://git.io/v9ha1
#!/usr/bin/env stack
-- stack script --resolver=lts-8.14 --package recursion-schemes --package transformers --package deriving-compat
{-# LANGUAGE TypeOperators
, DeriveFunctor
, DeriveFoldable
, DeriveTraversable
, DeriveGeneric
, TemplateHaskell
, MultiParamTypeClasses
, FlexibleInstances
@romac
romac / Data.Functor.Foldable.Monadic.hs
Created February 14, 2017 13:41
Data.Functor.Foldable.Monadic
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE FlexibleContexts #-}
module Data.Functor.Foldable.Monadic
( cataM
, anaM
, futuM
) where
import Protolude
scala> :paste
// Entering paste mode (ctrl-D to finish)
import inox._
import inox.trees._
import inox.trees.dsl._
import inox.solvers._
// Exiting paste mode, now interpreting.
@romac
romac / README.md
Created October 12, 2016 13:42
LLVM 3.8 Bitcode Resources
import shapeless._
import shapeless.ops.product._
import shapeless.syntax.std.product._
case class Foo(a: Int, b: String)
case class Bar(a: Int, b: String, c: Foo)
case class Empty()
case object Object
trait CaseFromProduct[T] {
/*
* Decompiled with CFR 0_108.
*
* Could not load the following classes:
* const$$anonfun
* const$$anonfun$lamConst
* scala.Function1
* scala.runtime.AbstractFunction1
*/
import scala.Function1;
@romac
romac / Church.hs
Last active October 18, 2015 00:01
{-# LANGUAGE RankNTypes #-}
-- Church encoding of various data-types.
-- Very much inspired by Gabriel Gonzalez's talk "Internet of Code":
-- http://begriffs.com/posts/2015-10-16-internet-of-code.html
module Church where
import Prelude hiding (map, sum, foldr, and, not)
-- List
@romac
romac / .travis.yml
Created September 9, 2015 11:25
Travis configuration for fast build of stack-based Haskell projects
language: haskell
sudo: false
cache:
directories:
- $HOME/.stack/
before_install:
- mkdir -p ~/.local/bin
@romac
romac / Makefile
Last active August 29, 2015 14:00
SHELL = bash
BIN_DIR = ./node_modules/.bin
BROWSERIFY = $(BIN_DIR)/browserify
.PHONY: all clean
all: prod.js dev.js
prod.js:
@romac
romac / Rx+React.jsx
Last active August 29, 2015 13:57
A simple example of how to load a React application's initial state with Rx.
'use strict';
var Rx = require('./rx-lite'),
React = require('react'),
Players = require('./Players'),
CurrentGames = require('./CurrentGames'),
JoinRequests = require('./JoinRequests');
var Dashboard = React.createClass({