Skip to content

Instantly share code, notes, and snippets.

View edsko's full-sized avatar

Edsko de Vries edsko

View GitHub Profile
@edsko
edsko / RTTI.hs
Created June 9, 2017 17:54
Run-time type information in Haskell
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE EmptyCase #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
repeatedly :: (a -> b -> b) -> ([a] -> b -> b)
repeatedly = flip . foldl' . flip
repeatedlyM :: Monad m => (a -> b -> m b) -> ([a] -> b -> m b)
repeatedlyM = flip . foldlM' . flip
foldlM' :: forall m a b. Monad m => (b -> a -> m b) -> b -> [a] -> m b
foldlM' f e = go e
where
go :: b -> [a] -> m b
-- | Recover tree structure from linearized form
--
-- Suppose we have a list of strings
--
-- > A
-- > B
-- > C
-- > D
-- > E
-- > F
{-# LANGUAGE RecordWildCards #-}
module SoundSeries.Util.SoupParser (
SoupParser
, parseSoup
-- * Combinators
, satisfy
, anyToken
, skipUntil
, lookupAttr
{-# LANGUAGE ConstraintKinds #-}
{-# OPTIONS_GHC -Wno-redundant-constraints #-}
module edundantConstraints (
keepRedundantConstraint
) where
-- | Can be used to silence individual "redundant constraint" warnings
--
-- > foo :: ConstraintUsefulForDebugging => ...
#!/bin/bash
if [ ! -n "$1" ]; then
export ACTIVATED=""
if [ -n "$PRE_ACTIVATED_PATH" ]; then
export PATH="$PRE_ACTIVATED_PATH"
unset PRE_ACTIVATED_PATH
fi
@edsko
edsko / parametricity.coq
Last active January 23, 2020 20:31
Formalization of a small part of the Parametricity Tutorial blog post
(* Developed using Coq 8.4pl5 *)
Require Import Coq.Setoids.Setoid.
Require Import Coq.Logic.ProofIrrelevance.
Require Import Coq.Logic.JMeq.
Set Implicit Arguments.
(* Auxiliary *)
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
@edsko
edsko / DependentServant.hs
Last active July 2, 2020 06:52
See "Dependently typed servers in Servant" (http://www.well-typed.com/blog/2015/12/dependently-typed-servers/) for the blog post accompanying this gist.
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RankNTypes #-}
@edsko
edsko / Sketch_QSM_LTL.hs
Created February 15, 2019 14:58
Using LTL formulae to check system states in quickcheck-state-machine
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StandaloneDeriving #-}
module Main where
import Data.IORef
import Data.TreeDiff