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
Lemma plus_1 : forall n, 1 + n = S n. | |
Proof. reflexivity. Qed. | |
Lemma f : forall n, S (1 + n) = S (S n). | |
Proof. intros n. rewrite plus_1. (* error on the last tactic *) | |
(* Error: Tactic generated a subgoal identical to the original goal. *) |
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 FlexibleContexts, MultiParamTypeClasses #-} | |
import Control.Monad.IO.Class | |
import Control.Monad.Except | |
import GHC.Stack (HasCallStack, CallStack, callStack, prettyCallStack) | |
data MyException = MyException CallStack String | |
deriving Show | |
merror :: (HasCallStack, MonadError MyException m) => String -> m 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
{-# LANGUAGE TemplateHaskell, DataKinds #-} | |
import GHC.Stack | |
f :: HasCallStack => Int | |
f = error "XXX" | |
g :: Int | |
g = f |
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 DeriveFunctor, DeriveFoldable, LambdaCase, RankNTypes #-} | |
import Data.Functor.Foldable | |
import Control.Monad.Free | |
import Data.Maybe | |
-- original | |
superCata | |
:: (Functor f, Foldable f) | |
=> (r -> r -> r) -> r -> (f r -> Maybe r) -> Fix f -> r |
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 FlexibleContexts, StandaloneDeriving, TypeFamilies, UndecidableInstances #-} | |
module Set where | |
import Data.List (nub) | |
newtype Set0 s = Set0 { elems :: [Elt s] } | |
deriving instance Eq (Elt s) => Eq (Set0 s) | |
deriving instance Ord (Elt s) => Ord (Set0 s) |
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
(* Some [IO] operations described by a sum type. *) | |
Inductive IO : Type := I | O (n : nat). | |
(* A function computes the result *type* of every operation. *) | |
Definition result : IO -> Type := fun io => | |
match io with | |
| I => nat | |
| O _ => unit | |
end. |
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
Require Export Ensembles. | |
Arguments Full_set {U}. | |
Arguments Empty_set {U}. | |
Arguments In {U}. | |
Arguments Intersection {U}. | |
Arguments Union {U}. | |
Arguments Complement {U}. | |
Definition Family A := Ensemble (Ensemble A). | |
Inductive FamilyUnion {T : Type} (F: Family T) : Ensemble T := |
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
Require Import ZArith List String Omega. | |
Require Import Paco.paco. | |
Import ListNotations. | |
Set Implicit Arguments. | |
Set Contextual Implicit. | |
CoInductive stream (A:Type) := | |
| snil : stream 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
import Control.Monad.Trans | |
import Control.Monad.Trans.Cont | |
bracket :: Monad m => ContT a m a -> ContT r m a | |
bracket (ContT f) = ContT $ \k -> f pure >>= k | |
defer :: Monad m => ContT () m () -> ContT r m () | |
defer (ContT f) = ContT $ \k -> k () <* f pure | |
main :: IO () |
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 | |
AllowAmbiguousTypes, | |
TypeApplications, | |
DataKinds, | |
ConstraintKinds, | |
TypeFamilies, | |
RankNTypes, | |
ScopedTypeVariables, | |
GADTs #-} |