Skip to content

Instantly share code, notes, and snippets.

@yksym
yksym / MealyLike.hs
Created January 2, 2018 05:27
MealyLike
{-# LANGUAGE PatternSynonyms, DeriveFunctor, FlexibleContexts, TemplateHaskell, RankNTypes #-}
{-# LANGUAGE GeneralizedNewtypeDeriving, StandaloneDeriving, FlexibleInstances, MultiParamTypeClasses #-}
import Data.Bifunctor (first)
import Control.Monad (forever)
import Control.Monad.Coroutine
import Control.Monad.Coroutine.SuspensionFunctors
import Control.Monad.Trans.Class
import Control.Monad.IO.Class
import Control.Monad.State.Class
import Control.Monad.State.Lazy
@yksym
yksym / Ex43.thy
Created December 18, 2017 04:00
concrete semantics Ex43
theory Ex43 imports Main begin
inductive star :: "( 'a ⇒ 'a ⇒ bool) ⇒ 'a ⇒ 'a ⇒ bool" for r where
refl: "star r x x" |
step: "r x y ⟹ star r y z ⟹ star r x z"
thm star.step [where ?z = "y"]
lemma r2star: "r x y ⟹ star r x y"
@yksym
yksym / Trans.thy
Last active December 16, 2017 05:29
memo: star to list
theory Trans
imports Main
begin
(* "Lectures on the Curry-Howard Isomorphism" Lemma 1.4.2 *)
inductive star :: "( 'a ⇒ 'a ⇒ bool) ⇒ 'a ⇒ 'a ⇒ bool" for r where
lift: "r x y ⟹ star r x y" |
trans: "star r x y ⟹ star r y z ⟹ star r x z"
inductive trans_list :: "( 'a ⇒ 'a ⇒ bool) ⇒ 'a list ⇒ bool" for r where
@yksym
yksym / CmpNat.idr
Created November 9, 2017 19:34
Idris勉強会で出た疑問
-- ref: https://github.com/idris-lang/Idris-dev/blob/0d3d2d66796b172e9933360aee51993a4abc624d/test/totality006/totality006.idr
import Data.So
antitrue : So False -> a
antitrue Oh impossible
total
eqNat : (n : Nat) -> (m : Nat) -> So (n == m) -> (n = m)
eqNat Z Z Oh = Refl
eqNat (S k) Z um = antitrue um -- なぜここでimpossibleが出来ない?
@yksym
yksym / IsFun.hs
Last active September 24, 2017 23:12
Is it function??
{-# LANGUAGE DataKinds, TypeOperators, KindSignatures, TypeFamilies #-}
{-# LANGUAGE UndecidableInstances, FlexibleInstances, FlexibleContexts #-}
module IsFun (
Proxy
, isFun
, cntArgs
) where
import Data.Proxy
@yksym
yksym / test_qual.cpp
Created August 27, 2015 11:43
bound qualification?
#include <typeinfo>
//g++ -std=gnu++0x jikken.cxx
//g++ -std=c++11 jikken.cxx
template <bool B> void sassert()
{
int dummy[B ? 1:-1];
dummy[0] = 0;
}