Skip to content

Instantly share code, notes, and snippets.

@yuga
yuga / exmaples.hs
Last active August 29, 2015 14:11
追加しようと思うexample
account1'' :: Relation () Account1
account1'' = relation $ do
a <- query account
wheres $ a ! Account.productCd' `in'` values ["CHK", "SAV", "CD", "MM"]
return $ Account1 |$| a ! Account.accountId'
|*| a ! Account.productCd'
|*| a ! Account.custId'
|*| a ! Account.availBalance'
data Account1 = Account1
@yuga
yuga / gist:328a5bdf885f1599d28d
Created December 11, 2014 03:21
SQLite3用のモジュール名をどれにあわせるか?
HSQL
--------------------
DB.HSQL.SQLite3
HDBC
--------------------
Database.HDBC.Sqlite3
HDBI
--------------------
@yuga
yuga / decimal.idr
Last active August 29, 2015 14:10
not deal with seriously
module decimal
record Decimal : Nat -> Type where
MkDecimal : (places : Nat) -> (mantissa : Integer) -> Decimal places
signum : Integer -> Integer
signum n = case compare n 0 of
LT => (-1)
EQ => 0
GT => 1
-- > chunkGroupBy (\x y -> x == y) 6 [0,0,0,0,1,1,1,2,2,2,2,2,3,3,3,3]
-- [[[0,0,0,0]],[[1,1,1]],[[2,2,2,2,2]],[[3,3,3,3]]]
--
-- > chunkGroupBy (\x y -> x == y) 7 [0,0,0,0,1,1,1,2,2,2,2,2,3,3,3,3]
-- [[[0,0,0,0],[1,1,1]],[[2,2,2,2,2]],[[3,3,3,3]]]
--
-- > chunkGroupBy (\x y -> x == y) 15 [0,0,0,0,1,1,1,2,2,2,2,2,3,3,3,3]
-- [[[0,0,0,0],[1,1,1],[2,2,2,2,2]],[[3,3,3,3]]]
--
-- > chunkGroupBy (\x y -> x == y) 16 [0,0,0,0,1,1,1,2,2,2,2,2,3,3,3,3]
@yuga
yuga / cow.bash
Created August 12, 2014 08:59
cowbuilderのバッドノウハウ集
#!/bin/bash
PRG=$(readlink -f "$0")
PRGDIR=$(dirname "${PRG}")
set -x
set -e
list=(
haskell-names-th_0.0.1.0.dsc
Definition five_not_even' : ~ ev 5 :=
fun (Hev5 : ev 5) =>
(fun (P : nat -> Prop) (* evの帰納法の原理*)
(f : P 0)
(f0 : forall n : nat, ev n -> P n -> P (S (S n))) =>
fix F (n : nat) (e : ev n) {struct e} : P n := (* eについて減少 *)
match e in (ev n0) return (P n0) with
| ev_0 => f
| ev_SS n1 ev1 => f0 n1 ev1 (F n1 ev1)
end)
@yuga
yuga / typeclass0.hs
Created June 27, 2014 07:35
typeclass0.hs の例でのコンパイルエラーを前に少し悩んだので。
class Producer p where
get :: Resource r => p -> r
class Resource a where
fire :: a -> Int
data A = A Int
data B = B Int
instance Producer A where
@yuga
yuga / andb_false.v
Last active August 29, 2015 14:02
Logic_J.vより抜粋。tacticを使わずに証明オブジェクトを手書きするのを試しているけど僕には難しい。
(* **** Exercise: 1 star (bool_prop) *)
(** **** 練習問題: ★ (bool_prop) *)
Theorem andb_false : forall b c,
andb b c = false -> b = false \/ c = false.
Proof.
intros b c H.
unfold andb in H.
destruct b.
right. apply H.
left. reflexivity.
@yuga
yuga / printf.idr
Created May 17, 2014 05:30
skills matterにVideoがあがっていたIdrisで書く型安全なprintf; youtube => http://youtu.be/fVBck2Zngjo
module Printf
%default total
data Format = FInt Format -- %d
| FString Format -- %s
| FOther Char Format -- [a-zA-Z0-9]
| FEnd --
format : List Char -> Format