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 #-} | |
module Edge where | |
import Control.Applicative | |
import Control.Arrow | |
import Control.Category | |
import Control.Monad.Morph | |
import Control.Monad.State.Strict | |
import Pipes.Core |
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
-- Proofs that something is not an element of a vector | |
using ( x : t, y : t, xs : Vect n t ) | |
data NElem : t -> Vect n t -> Type where | |
Empty : NElem x [] | |
Miss : Not (y = x) -> NElem x xs -> NElem x (y :: xs) | |
namespace Uniq | |
-- Vector types where each element is unique | |
data Uniq : Nat -> Type -> Type 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
module Rel | |
DecProofType : {a:Type} -> Dec a -> Type | |
DecProofType {a} (Yes _) = a | |
DecProofType {a} (No _) = a -> _|_ | |
decProof : {a:Type} -> (dec : Dec a) -> DecProofType dec | |
decProof (Yes x) = x | |
decProof (No x) = x |
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 FlexibleInstances #-} | |
{-# LANGUAGE RankNTypes #-} | |
{-# LANGUAGE TypeFamilies #-} | |
module Dbs where | |
import Control.Monad.Morph | |
import Control.Monad.ST (RealWorld, ST, runST, stToIO) | |
import Control.Monad.Trans.Free | |
import Data.Array.ST |
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 Arrows #-} | |
{-# LANGUAGE FlexibleContexts #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE MultiParamTypeClasses #-} | |
{-# LANGUAGE TemplateHaskell #-} | |
module Ex where | |
import Control.Applicative | |
import Control.Arrow |
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
instance Monoid Bool where | |
mempty = True | |
x <> y = x == y | |
[ mempty <> x == x ] | |
True <> True == True | |
True <> False == False | |
[ x <> mempty == x ] | |
-- dispatched by symmetry of (==) |
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
protocol Viewl { | |
typealias El | |
func uncons() -> (El, Self)? | |
} | |
func head<X:Viewl>(x: X) -> X.El? { return x.uncons()?.0 } | |
func tail<X:Viewl>(x: X) -> X? { return x.uncons()?.1 } | |
extension String:Viewl { | |
typealias El = Character |
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
func id <A>(a: A) -> A { return a } | |
func fix <A>(f: A -> A) -> A { return f(fix(f)) } | |
func loop<A>() -> A { return fix(id) } | |
protocol Viewl { | |
typealias El | |
func uncons() -> (El, Self)? | |
} | |
func head<X:Viewl>(x: X) -> X.El? { return x.uncons()?.0 } |
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
enum Maybe<A> { | |
case Nothing, Just(A) | |
func map<B> (f: A -> B) -> Maybe<B> { | |
switch self { | |
case .Nothing: return .Nothing | |
case .Just(let a): return .Just(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
{-# LANGUAGE DeriveFoldable #-} | |
{-# LANGUAGE DeriveFunctor #-} | |
{-# LANGUAGE DeriveTraversable #-} | |
{-# LANGUAGE FlexibleContexts #-} | |
{-# LANGUAGE TypeFamilies #-} | |
module Bin where | |
import Control.Applicative | |
import qualified Data.Foldable as F |
OlderNewer