This file contains hidden or 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
{-# OPTIONS --type-in-type #-} | |
module Hurkens where | |
----------------------- | |
O = Set | |
Bottom : O | |
Bottom = (A : O) β A |
This file contains hidden or 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
package cat | |
object CAT { | |
// system traits | |
sealed trait Type[Self <: Type[Self]] | |
sealed trait Of[Self <: Of[Self, T], T <: Type[T]] | |
// types | |
case class Ob() |
This file contains hidden or 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
// Scala Types are objects of Cartesian Closed Category | |
// (w/o equalities, probably not a category, sorry) | |
object CCC { | |
// category structure | |
def id[T0]: T0=>T0 = x0=>x0 | |
def mul[T1, T2, T3](f23: T2=>T3, f12: T1=>T2): (T1=>T3) = x1 => f23(f12(x1)) | |
// terminal object; adjunction; | |
type _1_ = Unit |
This file contains hidden or 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
sealed trait Free[F[_], A] { self => | |
final def map[B](ab: A => B): Free[F, B] = Free.flatMap(self, ab andThen (Free.point[F, B](_))) | |
final def flatMap[B](afb: A => Free[F, B]): Free[F, B] = Free.flatMap(self, afb) | |
final def interpret[G[_]: Monad](fg: F ~> G): G[A] = self match { | |
case Free.Point(a0) => a0().point[G] | |
case Free.Effect(fa) => fg(fa) | |
case fm : Free.FlatMap[F, A] => | |
val ga0 = fm.fa.interpret[G](fg) | |
ga0.flatMap(a0 => fm.afb(a0).interpret[G](fg)) | |
} |
This file contains hidden or 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
ok | |
<<"( Ξ» (P.el: ( β (_: ( β (A.Carrier.El: *1)\n β ( β (A.Carrier.To: ( β (a: A.Carrier.El)\n β ( β (b: A.Carrier.El)\n β *0)))\n β ( β (A.Carrier.Trans: ( β (e1: A.Carrier.El)\n β ( β (e2: A.Carrier.El)\n β ( β (e3: A.Carrier.El)\n β ( β (_: ((A.Carrier.To e1) e2))\n β ( β (_: ((A.Carrier.To e2) e3))\n β ((A.Carrier.To e1) e3)))))))\n β ( β (A.Mk.el: A.Carrier.El)\n β ( β (A.Mk.ok: ((A.Carrier.To A.Mk.el) A.Mk.el))\n β A.Carrier.El))))))\n β *0))\nβ ( Ξ» (P.ok: ( β (a1.el: ( β (A.Carrier.El: *1)\n β ( β (A.Carrier.To: ( β (a: A.Carrier.El)\n β ( β (b: A.Carrier.El)\n β *0)))\n β ( β (A.Carrier.Trans: ( β (e1: A.Carrier.El)\n β ( β (e2: A.Carrier.El)\n β ( β (e3: A.Carrier.El)\n β ( β (_: ((A.Carrier.To e1) e2))\n β ( β (_: ((A.Carrier.To e2) e3))\n β ((A.Carrier.To e1) e3)))))))\n β ( β (A.Mk.el: A.Carrier.El)\n β ( β (A.Mk.ok: ((A.Carrier.To A.Mk.el) A.Mk.el))\n β A.Carrier.El))))))\n β ( β (a1.ok: ( β (A1. |
This file contains hidden or 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
namespace foo | |
definition bool := β a : Prop, a β a β a | |
definition tt : bool := Ξ» (a : Prop) (c d : a), c | |
definition ff : bool := Ξ» (a : Prop) (c d : a), d | |
definition ind_on_T := β P : bool β Prop, β a : bool, P tt β P ff β P a | |
definition ind_on : ind_on_T := Ξ» (P : bool β Prop) (a : bool) (t : P tt) (f : P ff), a (P a) t f | |
check ind_on |
This file contains hidden or 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
-- #Prop | |
* |
This file contains hidden or 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
Fix : (Type -> Type) -> Type | |
Fix f = {x : Type} -> (f x -> x) -> x | |
fold : Functor f => {x : Type} -> (f x -> x) -> Fix f -> x | |
fold k t = t k | |
embed : Functor f => f (Fix f) -> Fix f | |
embed s k = k (map (fold k) s) | |
project : Functor f => Fix f -> f (Fix f) |
This file contains hidden or 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
%default total | |
data Mu : (Type -> Type) -> Type where | |
In : f (Mu f) -> Mu f | |
out : Mu f -> f (Mu f) | |
out (In x) = x | |
data LstF : Type -> Type -> Type where | |
LF : ({c : Type} -> (Maybe (a, Unit -> c, b) -> c) -> c) -> LstF a b |
This file contains hidden or 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 ExistentialQuantification #-} | |
{-# LANGUAGE Rank2Types #-} | |
import Data.Maybe | |
data List a = L (forall b. (Maybe (a, (b, List a)) -> b) -> b) | |
nil :: List a | |
nil = L (\f -> f Nothing) |