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
(* Compile with: | |
$ ocamlfind ocamlc -package angstrom,stdio -linkpkg tychk.ml -o tychk | |
Example use: | |
$ ./tychk <<EOF | |
> let f = (fun x -> x) : forall a. a -> a | |
> in f f | |
> EOF | |
input : forall a. a -> a | |
*) |
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
module C : sig | |
type t | |
val empty : t | |
val one : char -> t | |
val union : t -> t -> t | |
val inter : t -> t -> t | |
val top : t | |
val mem : char -> t -> bool | |
val make : (char -> bool) -> t | |
val equal : t -> t -> bool |
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
{-# LANGUAGE TemplateHaskell #-} | |
{-# LANGUAGE GADTs #-} | |
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE MultiParamTypeClasses #-} | |
module Bad where | |
import Prelude | |
import Data.Kind ( Type ) | |
import Generics.MultiRec.TH |
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
{-# language Strict, LambdaCase, BlockArguments #-} | |
{-# options_ghc -Wincomplete-patterns #-} | |
{- | |
Minimal demo of "glued" evaluation in the style of Olle Fredriksson: | |
https://github.com/ollef/sixty | |
The main idea is that during elaboration, we need different evaluation |
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
## Principal type-schemes for functional programs | |
**Luis Damas and Robin Milner, POPL '82** | |
> module W where | |
> import Data.List | |
> import Data.Maybe | |
> import Data.Function |
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
(** {0 Elaboration with Record Patching and Singleton Types} | |
This is a small implementation of a dependently typed language with | |
dependent record types, with some additional features intended to make it | |
more convenient to use records as first-class modules. It was originally | |
ported from {{: https://gist.github.com/mb64/04315edd1a8b1b2c2e5bd38071ff66b5} | |
a gist by mb64}. | |
The type system is implemented in terms of an ‘elaborator’, which type | |
checks and tanslates a user-friendly surface language into a simpler and |
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
// Faster solution for: | |
// http://www.boyter.org/2017/03/golang-solution-faster-equivalent-java-solution/ | |
// With threading. | |
// g++ -std=c++11 -Wall -Wextra -O3 -pthread | |
// On my computer (i5-6600K 3.50 GHz 4 cores), takes about ~160 ms after the CPU | |
// has warmed up, or ~80 ms if the CPU is cold (due to Turbo Boost). | |
// How it works: Start by generating a list of losing states -- states where the | |
// game can end in one turn. Generate a new list of states by running the game |
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
/- | |
A proof of the correctness of an arithmetic expression compiler in Lean 4. | |
Ported from [expcompile.v], which is part of Derek Dreyer and Gert Smolka's | |
[course material]. | |
[expcompile.v]: https://www.ps.uni-saarland.de/courses/sem-ws17/expcompile.v | |
[course material]: https://courses.ps.uni-saarland.de/sem_ws1718/3/Resources | |
-/ |
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
-- https://icfp21.sigplan.org/details/icfp-2021-papers/21/Calculating-Dependently-Typed-Compilers-Functional-Pearl- | |
{-# LANGUAGE GADTs, DataKinds, TypeOperators, TypeFamilies, TypeApplications, KindSignatures, ScopedTypeVariables #-} | |
import Control.Applicative | |
import Data.Kind | |
import Data.Type.Equality | |
type family (a :: Bool) || (b :: Bool) :: Bool where | |
'False || b = b | |
'True || b = 'True |