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 Data.Map ((!), fromList, Map) | |
data Direction = L | R | |
type Symbol = Char | |
type State = Maybe Int | |
type Rules = Map (State, Symbol) (Symbol, Direction, State) | |
turingMachine :: Rules -> Symbol -> [Symbol] -> [Symbol] | |
turingMachine rules blank tape = let |
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 qualified Data.Vector as V | |
import qualified Data.Vector.Unboxed as UV | |
import qualified Data.ByteString.Char8 as B | |
import Data.Ix | |
import Text.Printf | |
import Data.List | |
import Data.Ord | |
import System.Environment | |
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
module NatInduction where | |
data ℕ : Set where | |
zero : ℕ | |
suc : ℕ → ℕ | |
ℕ-ind : (prop : ℕ → Set) | |
→ (zero_proof : prop zero) | |
→ (ind_hyp : ∀ n → prop n → prop (suc n)) | |
→ (n : ℕ) |
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 System.Environment | |
import Data.Word | |
import Data.Char | |
import Control.Arrow | |
import Data.Function | |
infixr 5 :> | |
data Mem = {- UNPACK -} !Word8 :> Mem | |
eval :: Mem -> Mem -> String -> IO (Mem, Mem) |
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 LambdaCase #-} | |
import qualified Data.Attoparsec.Text as P | |
import qualified Data.Text as T | |
import qualified Data.Text.IO as TIO | |
import Control.Applicative | |
import Data.Char | |
import Data.List | |
import Data.Word |
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 LambdaCase #-} | |
import qualified Data.PQueue.Min as Q | |
import Control.Arrow | |
import Data.Function | |
data Tree | |
= Empty | |
| Leaf {weight :: Double} | |
| Node {weight :: Double, _left, _right :: Tree} |
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 RankNTypes, TypeSynonymInstances, FlexibleInstances #-} | |
type ChNat a = (a -> a) -> a -> a | |
generalize :: ChNat Int -> (forall a. ChNat a) | |
generalize n = foldr (.) id . replicate (fromEnum n) | |
instance Num (ChNat Int) where | |
fromInteger = toEnum . fromIntegral | |
a + b = \f -> a f . b 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
import Control.Monad.Cont | |
import Data.Function | |
getLabel = ContT fix | |
goto label = lift label | |
getLoop x = ContT (\k -> let f x' = ContT (\_ -> k (f, x')) in k (f, x)) | |
gotoTest :: 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
module NatProps where | |
open import Relation.Binary.PropositionalEquality | |
open import Relation.Nullary | |
open import Data.Sum | |
open import Function | |
data ℕ : Set where | |
zero : ℕ | |
suc : ℕ → ℕ |
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 qualified Criterion.Main as Crit | |
import qualified Test.Tasty.QuickCheck as QC | |
import qualified Test.Tasty as Tasty | |
import Data.List | |
import Data.List.Split | |
import System.Random | |