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.Free -- from category-extras | |
data WebF r = Display String r | Form String (String -> r) | |
instance Functor WebF where | |
fmap f (Display m r) = Display m (f r) | |
fmap f (Form m g) = Form m (f . g) | |
type Web = Free WebF |
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, TypeOperators, KindSignatures, ScopedTypeVariables #-} | |
import Control.Functor.HigherOrder | |
import Control.Functor.Extras | |
newtype K k (r :: * -> *) a = K k | |
newtype I f (r :: * -> *) a = I (r (f a)) | |
newtype E (r :: * -> *) a = E a | |
data (f :*: g) (r :: * -> *) a = f r a :*: g r a | |
data (f :+: g) (r :: * -> *) a = L (f r a) | R (g r 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 GADTs, KindSignatures #-} | |
data Val = B Int | Unit | Pair Val Val | In1 Val | In2 Val | Closr (Val -> Cnt -> Ans) | Contx Val Cnt | |
type Cnt = Val -> Ans | |
type Env = Ide -> Either Val Cnt | |
type Ans = IO () | |
type Ide = String | |
data E :: * -> * 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
{-# LANGUAGE MultiParamTypeClasses, KindSignatures #-} | |
module CBV where | |
import Control.Functor | |
import Control.Category | |
import Control.Category.Object | |
import Control.Category.Associative | |
import Control.Category.Braided | |
import Control.Category.Cartesian | |
import Control.Category.Cartesian.Closed |
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 TypeOperators, TypeFamilies, EmptyDataDecls, UndecidableInstances, RankNTypes, FlexibleContexts #-} | |
import Prelude hiding ((.), id) | |
import Control.Category | |
import Control.Arrow (Kleisli(..)) | |
type family Obj (f :: * -> *) a :: * | |
class CFunctor f where | |
type Dom f :: * -> * -> * | |
type Cod 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
<script> | |
var r = /\s/, a = []; | |
for (var i = 0; i < 0x10000; i++) | |
if (r.test(String.fromCharCode(i))) | |
a.push(i.toString(16)); | |
document.write(a); | |
</script> | |
<p>IE: 9,a,b,c,d,20</p> | |
<p>FF: 9,a,b,c,d,20,a0,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,200a,200b,2028,2029,3000</p> | |
<p>Chrome/Safari/Opera: |
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
data Z = Z | |
newtype S n = S n | |
data family Fin n a b :: * | |
data instance Fin (S n) n Z = FZ | |
newtype instance Fin (S n) a (S b) = FS (Fin (S n) (S a) b) |
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 NoMonomorphismRestriction, TypeSynonymInstances, FlexibleInstances, MultiParamTypeClasses #-} | |
class ExpSYM repr where | |
lit :: Int -> repr | |
neg :: repr -> repr | |
add :: repr -> repr -> repr | |
class Ann repr e where | |
a :: e -> repr -> repr |
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 TypeFamilies, EmptyDataDecls, TypeOperators, FlexibleInstances, ScopedTypeVariables #-} | |
import Data.Maybe (catMaybes) | |
import Data.List (intercalate) | |
import Control.Applicative (liftA2) | |
-- Void datatypes as labels, which are easier to work with | |
data K a | |
data X | |
data Rec |
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 EmptyDataDecls #-} | |
data Empty | |
data Loop = CLoop (Loop -> Empty) | |
loop_step :: Loop -> Empty | |
loop_step b@(CLoop f) = f b | |
loop :: Empty |
OlderNewer