Skip to content

Instantly share code, notes, and snippets.

@tokiwoousaka
tokiwoousaka / gist:8554260
Last active January 4, 2016 02:19
リストモナドのEff版的な
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ExistentialQuantification #-}
module Main where
newtype Eff a = Eff { runEff :: forall w. (a -> VE w) -> VE w }
instance Monad Eff where
--return :: a -> Eff a
return x = Eff $ \k -> k x
--(>>=) :: Eff a -> (a -> Eff b) -> Eff b
m >>= f = let

テーマ「型」

6さいカンファレンスのレジュメ的な何か

自己紹介

はいはい、どうも、ちゅーんさんですよ。

module Main where
contents::[(String, Int)]
contents =
[ ("start", 1)
, ("string", 11)
, ("number", 15)
]
formatRec :: (Int, (String, Int)) -> String
@tokiwoousaka
tokiwoousaka / gist:6666757
Created September 23, 2013 05:30
(。ŏ﹏ŏ)ふぇぇ…
{-# LANGUAGE TypeSynonymInstances #-}
module Main where
class Hoge h where
hoge :: h a -> String
type Foo a = (a, a)
instance Hoge Foo where -- => Type synonym `Foo' should have 1 argument, but has been given none
hoge _ = "foooooo!"
@tokiwoousaka
tokiwoousaka / gist:6655082
Last active December 23, 2015 15:19
ちゅ〜りっぷ
module Main where
import Sound.Sarasvati.Base
sinl :: Float -> [Float]
sinl x = map sin $ f 0
where f v = v : f (v + (x / 4410))
zips :: [a] -> [(a, a)]
zips x = zip x x
@tokiwoousaka
tokiwoousaka / .vimrc
Created June 12, 2013 15:56
仕事先で使えるよう公開
" 検索文字列ハイライト
set hlsearch
"""""""""""""""""""""""""""""""""""""""""""""""""
" 実行
:function ExecFile()
:w
:if &filetype == "haskell"
@tokiwoousaka
tokiwoousaka / gist:5507329
Last active December 16, 2015 22:29
egisonではリストもmaybeも、matcherを適切に実装する事で、同じマッチ式でパターンマッチする事ができる。
(define $maybe
(lambda [$a]
(matcher {
;; <primitive-pp>
[,$val [a] {[$tgt
(match [val tgt] [(maybe a) (maybe a)] {
[[<just $x> <just ,x>] {[x]}]
[[<nothing> <nothing>] {[]}]
[_ {}]})]}]
;; <primitive-dp>
@tokiwoousaka
tokiwoousaka / gist:5495959
Last active December 16, 2015 20:58
たけとんさんの書いたeitherで遊んでみた
(define $maybe
(lambda [$a]
(matcher {
;; <primitive-pp>
[,$val [a] {[$tgt
(match [val tgt] [(maybe a) (maybe a)] {
[[<just $x> <just ,x>] {[x]}]
[[<nothing> <nothing>] {[]}]
[_ {}]})]}]
;; <primitive-dp>
@tokiwoousaka
tokiwoousaka / gist:5481512
Last active December 16, 2015 18:59
egisonを使ったMaybeのmatcher定義
(define $maybe
(lambda [$a]
(matcher {
;; <primitive-pp>
[,$val [a] {[$tgt
(match [val tgt] [(maybe a) (maybe a)] {
[[<just $x> <just ,x>] {[x]}]
[[<nothing> <nothing>] {[]}]
[_ {}]})]}]
;; <primitive-dp>
@tokiwoousaka
tokiwoousaka / gist:5480615
Last active December 16, 2015 18:49
egisonのmatcherの定義。 見様見真似で書いてみたけどどうしてこーなるのか解らんw
(define $hoge
(matcher {
;; <primitive-pp>
[,$val [] {[$tgt
(match [val tgt] [hoge hoge] {
[[<aaa> <aaa>] {[]}]
[[<bbb> <bbb>] {[]}]
[[<ccc> <ccc>] {[]}]
[_ {}]})]}]
;; <primitive-dp>