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
{-# OPTIONS --postfix-projections --without-K #-} | |
-- Notes for https://www.youtube.com/watch?v=RXKRepPm0ps | |
-- checked with Agda 2.6.1 + stdlib 1.5 | |
open import Data.Product renaming (proj₁ to ₁; proj₂ to ₂) | |
open import Relation.Binary.PropositionalEquality | |
renaming (subst to tr; sym to infix 6 _⁻¹; trans to infixr 5 _◾_; cong to ap) | |
open import Data.Nat |
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
{- | |
-- Compiler: staging, memory layout control, etc (small + self-hosting + useful soon) | |
-- Surface language: | |
1. CBV + side effects (ML) | |
2. CBV + typed effect system: | |
- Eff monad | |
- Eff monad, row of effects | |
f : Int -> Eff [IO, Exc e, MutRef a, MutRef b] Int |
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
-- solution to https://github.com/effectfully/haskell-challenges/blob/master/h3-transform-typed/README.md | |
{-# LANGUAGE GADTs #-} | |
module Lib where | |
import Data.Proxy | |
import Data.Typeable | |
data Scheme a where |
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
-- Solution to challenge: https://github.com/effectfully/haskell-challenges/tree/master/force-elems | |
-- (Spoiler) | |
data EC = Elem | Con | |
data T a = T {ec :: !EC, unT :: a} | |
appEC :: EC -> (a -> b) -> a -> b | |
appEC Elem f a = f $! a | |
appEC Con f a = f 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
{-# OPTIONS --without-K #-} | |
open import Data.Bool | |
open import Data.Product | |
open import Relation.Binary.PropositionalEquality | |
open import Data.Empty | |
open import Function | |
surj : {A B : Set} → (A → B) → Set | |
surj f = ∀ b → ∃ λ a → f a ≡ b |
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
{-# OPTIONS --rewriting #-} | |
module cont-cwf where | |
open import Agda.Builtin.Sigma | |
open import Agda.Builtin.Unit | |
open import Agda.Builtin.Bool | |
open import Agda.Builtin.Nat | |
open import Data.Empty | |
open import Relation.Binary.PropositionalEquality public using (_≡_; refl; trans; subst; cong) |
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
{-# language Strict, BangPatterns #-} | |
data Tm = Var Int | App Tm Tm | Lam Tm | Fix Tm deriving (Show, Eq) | |
data Val = VVar Int | VApp Val Val | VLam [Val] Tm | VFix [Val] Tm | |
isCanonical :: Val -> Bool | |
isCanonical VLam{} = True | |
isCanonical _ = False | |
eval :: [Val] -> Tm -> Val |
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
open import Data.Unit | |
open import Data.Product | |
infixr 4 _⇒_ _*_ ⟨_,_⟩ _∘_ | |
data Obj : Set where | |
∙ : Obj | |
base : Obj | |
_*_ : Obj → Obj → Obj |
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, TypeApplications, ScopedTypeVariables, | |
PartialTypeSignatures, ViewPatterns #-} | |
{-# options_ghc -Wno-partial-type-signatures #-} | |
import qualified Data.Primitive.PrimArray as A | |
import GHC.Exts (IsList(..)) | |
import Data.Bits | |
import Data.Word | |
import Control.Monad.ST.Strict |