This file contains hidden or 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
| ;; -*- mode: emacs-lisp -*- | |
| ;; This file is loaded by Spacemacs at startup. | |
| ;; It must be stored in your home directory. | |
| (defun dotspacemacs/layers () | |
| "Configuration Layers declaration. | |
| You should not put any user code in this function besides modifying the variable | |
| values." | |
| (setq-default | |
| ;; Base distribution to use. This is a layer contained in the directory |
This file contains hidden or 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 Microsoft.FSharp.Quotations | |
| // <@ fun x -> (% <@ x @> ) @> ~ lambda (fun x -> x) | |
| let lambda (f : Expr<'T> -> Expr<'R>) : Expr<'T -> 'R> = | |
| let var = new Var("__temp__", typeof<'T>) | |
| Expr.Cast<_>(Expr.Lambda(var, f (Expr.Cast<_>(Expr.Var var)))) | |
| // fixed-point combinator | |
| let rec fix : (('Τ -> 'R) -> ('Τ -> 'R)) -> 'Τ -> 'R = fun f x -> |
This file contains hidden or 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
| #lang racket | |
| (require rackunit) | |
| #| Negation Normal Form |# | |
| ;; TODO: Add biconnection for NNF transformation | |
| (define (nnf prop) | |
| (match prop |
This file contains hidden or 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
| class Shift: | |
| def __init__(self, fun): | |
| self.fun = fun | |
| def map(self, f): return Shift(lambda k: self.fun(lambda x: k(f(x)))) | |
| def bind(self, f): return Shift(lambda k: self.fun(lambda x: f(x).fun(k))) | |
| def bind2(self, f): | |
| def aux(k): |
This file contains hidden or 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
| trait Futamura1 { | |
| // Roughly follow the idea from http://blog.sigfpe.com/2009/05/three-projections-of-doctor-futamura.html | |
| type P[_] // program representation type | |
| type M[_] // machine type | |
| /* To run a machine: */ | |
| def run[A](ma: M[A]): A | |
| /* The specializer: a machine that | |
| takes a program representation of A => B, |
This file contains hidden or 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
| object Basic { | |
| trait Expr | |
| case class Var(x: String) extends Expr | |
| case class Lam(x: String, body: Expr) extends Expr | |
| case class App(e1: Expr, e2: Expr) extends Expr | |
| trait Value | |
| case class FunV(f: Value ⇒ Value) extends Value | |
| type Env = Map[String, Value] |
This file contains hidden or 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
| ;; Use Melpa | |
| (require 'package) | |
| (custom-set-variables | |
| ;; custom-set-variables was added by Custom. | |
| ;; If you edit it by hand, you could mess it up, so be careful. | |
| ;; Your init file should contain only one such instance. | |
| ;; If there is more than one, they won't work right. | |
| '(custom-safe-themes | |
| (quote |
This file contains hidden or 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
| package duality.of.sorts | |
| // A Duality of Sorts | |
| // Ralf Hinze, Jose Pedro Magalhaes, Nicolas Wu | |
| // in The Beauty of Functional Code, LNCS 8106, Springer | |
| // This paper: makes the duality between folds and unfolds explicit, | |
| // defines sorting algorithms as folds of unfolds, | |
| // and as unfolds of folds. |
This file contains hidden or 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
| package thermo | |
| /* Scala implementation of delimited continuations using "thermometer continuations" from | |
| * Capturing the future by replaying the past (functional pearl) | |
| * https://dl.acm.org/doi/10.1145/3236771 | |
| * Based on its Java artifact: https://github.com/jkoppel/thermometer-continuations | |
| * Written and translate to Scala by Guannan Wei. | |
| */ | |
| trait Block[A] { |
OlderNewer