description |
---|
Inversion hell.
|
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
{- cabal: | |
build-depends: base, random, containers | |
-} | |
{-# LANGUAGE GADTs, ViewPatterns, GHC2021 #-} | |
import Text.Printf | |
import Control.Monad (liftM, ap) | |
import Data.Function (on) | |
import Data.List (sort, minimumBy) | |
import System.Random | |
import qualified Data.Map as M |
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 import Data.Nat | |
open import Data.Nat.Properties | |
open import Relation.Binary.PropositionalEquality | |
open import Data.Product | |
open import Data.Sum | |
open import Relation.Nullary | |
module MonoidNat3 where | |
data Expr : Set where |
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
module CoDebruijn where | |
open import Data.Product using (_×_; _,_; ∃-syntax) | |
open import Relation.Binary.PropositionalEquality.Core using (_≡_; refl) | |
data Context : Set where | |
O : Context | |
1+_ : Context → Context | |
data Singleton : Context → Set where |
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
(** {1 Syntax} *) | |
(** Expressions. *) | |
type expr = | |
| Var of cont * int | |
(** Local references. | |
Thorin is a "blockless" IR, so we can reference arguments of | |
other nodes by adding a data dependency edge, which implicitly | |
nests the two nodes. *) |
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
type var = string | |
type term = Var of var | |
| Lam of var * term | |
| App of term * term | |
| Fix of var * term (* only used for functions *) | |
| Lit of int | |
type value = Int of int | |
| Fun of (value -> 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
import System.Environment (getArgs) | |
import Control.Monad (guard, forM_) | |
import System.Random (RandomGen) | |
import qualified System.Random as Random | |
import Data.Map.Strict (Map) | |
import qualified Data.Map.Strict as Map |
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
-- Polarized lambda calculus to A-normal form | |
-- With eta-expansion and call-saturation | |
type Ix = Int | |
type Lvl = Int | |
data Ty = TInt | |
deriving (Show) | |
data TFun = TFun [Ty] Ty | |
deriving (Show) |
Elaboration is, broadly speaking, taking user-written syntax and converting it to "core" syntax by filling in missing information and at the same time validating that the input is well-formed.
I haven't been fully happy with formalizations that I previously used, so I make a new attempt here. I focus on a minimal dependently typed case.
NewerOlder