Skip to content

Instantly share code, notes, and snippets.


Jiří Beneš jiribenes

View GitHub Profile
AndrasKovacs / NbESharedQuote.hs
Last active May 2, 2023 01:02
NbE with implicit sharing in quotation
View NbESharedQuote.hs
At ICFP 2022 I attended a talk given by Tomasz Drab, about this paper:
"A simple and efficient implementation of strong call by need by an abstract machine"
This is right up my alley since I've implemented strong call-by-need evaluation
quite a few times (without ever doing more formal analysis of it) and I'm also
interested in performance improvements. Such evaluation is required in
conversion checking in dependently typed languages.
brendanzab /
Last active September 13, 2022 06:12
Elaboration with Singletons and Record patching
(** {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 {{:}
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
mb64 /
Last active December 13, 2022 21:36
Bidirectional typechecking for higher-rank polymorphism in OCaml, without polymorphic subtyping
(* Compile with:
$ ocamlfind ocamlc -package angstrom,stdio -linkpkg -o tychk
Example use:
$ ./tychk <<EOF
> let f = (fun x -> x) : forall a. a -> a
> in f f
input : forall a. a -> a
sjoerdvisscher / CalcComp.hs
Created August 25, 2021 12:20
Calculating Dependently-Typed Compilers
View CalcComp.hs
{-# 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
robrix / FoldsAndUnfolds.hs
Created March 31, 2021 22:44
Recursion schemes over lists, in contrast with foldr/unfoldr
View FoldsAndUnfolds.hs
module FoldsAndUnfolds where
import Data.List -- for unfoldr
class Functor f => Recursive f t | t -> f where
project :: t -> f t
cata :: (f a -> a) -> t -> a
cata alg = go where go = alg . fmap go . project

Program Analysis, a Big Happy Family

The idea behind program analysis is simple, right? You just want to know stuff about your program before it runs, usually because you don't want unexpected problems to arise (those are better in movies.) Then why looking at Wikipedia gives you headaches? Just so many approaches, tools, languages 🤯

In this article I would like to give a glimpse of an overarching approach to program analysis, based on ideas from abstract interpretation. My goal is not to pinpoint a specific technique, but rather show how they have common core concepts, the differences being due mostly to algorithmic challenges. In other words, static analysis have a shared goal, but it's a challenge to make them precise and performant.

Code is meant to be executed by a computer. Take the following very simple function:

fun cantulupe(x) = {
brendanzab / ArithExprs.lean
Last active September 22, 2021 09:38
A proof of the correctness of an arithmetic expression compiler and decompiler in Lean 4.
View ArithExprs.lean
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].
[course material]:
domenkozar /
Created January 28, 2021 11:13
Automated testing for 404/500 errors
module Spec where
import Quickstrom
import Data.Foldable (any)
import Data.Maybe (maybe)
import Data.Tuple (Tuple(..))
import Data.String.CodeUnits (contains)
import Data.String.Pattern (Pattern(..))
readyWhen = "body"
domenkozar / Repl.hs
Last active February 25, 2021 23:25
Cachix Server Repl using hint
View Repl.hs
{-# OPTIONS_GHC -fno-warn-orphans #-}
module Repl where
import Cachix.Config (readConfig)
import Cachix.Env (setupApp)
import Cachix.Server.Prelude
import qualified Control.Exception.Safe as Safe
import qualified Language.Haskell.Interpreter as Interpreter
import Protolude
AndrasKovacs / GluedEval.hs
Last active November 4, 2022 04:41
Non-deterministic normalization-by-evaluation in Olle Fredriksson's flavor.
View GluedEval.hs
{-# language Strict, LambdaCase, BlockArguments #-}
{-# options_ghc -Wincomplete-patterns #-}
Minimal demo of "glued" evaluation in the style of Olle Fredriksson:
The main idea is that during elaboration, we need different evaluation