Skip to content

Instantly share code, notes, and snippets.

{-# LANGUAGE TemplateHaskell, RankNTypes #-}
module Main where
import Control.Lens
import Control.Monad.State
import Data.List
sample :: [String]
sample =
[ "hoge"
, "piyo"
モナド則: (m >>= g) >>= h == m >>= (\x -> g x >>= h)
定義: f >=> g == \x -> f x >>= g
命題:(f >=> g) >=> h == f >=> (g >=> h)
(f >=> g) >=> h
== (\x -> f x >>= g) >=> h -- (>=>)の定義
== \y -> (\x -> f x >>= g) y >>= h -- (>=>)の定義
== \y -> (f y >>= g) >>= h
== \y -> f y >>= (\z -> g z >>= h) -- モナド則
== \y -> f y >>= (g >=> h) -- (>=>)の定義
var move_rand_pos = function (obj) {
obj.x = rand(SCREEN_WIDTH - CHARACTER_WIDTH);
obj.y = rand(SCREEN_HEIGHT - CHARACTER_HEIGHT);
}
" 検索文字列ハイライト
set hlsearch
"""""""""""""""""""""""""""""""""""""""""""""""""
" 実行
:function ExecFile()
:w
:if &filetype == "haskell"
:! runghc %
module Main where
import Control.Lens
import Control.Monad.Takahashi
import Control.Monad.State
main :: IO ()
main = do
writeSlide "Out.html" presentation
putStrLn "Success."
@tokiwoousaka
tokiwoousaka / gist:fe0d203de8a1305e6ad9
Last active August 29, 2015 14:16
リスト処理で簡単な波形を作ってSarasvati(開発版:https://github.com/tokiwoousaka/Sarasvati/tree/develop/4 )に流し込むテスト。
module Main where
import Sound.Sarasvati
import Control.DeepSeq
import Control.Arrow
main :: IO ()
main = do
putStrLn "music building..."
sarasvatiOutput defaultConfig . vol 0.5 0.5 $!! concat [music, music, r 8]
return ()
@tokiwoousaka
tokiwoousaka / gist:13ace08ad2313b0ea6b5
Last active August 29, 2015 14:16
同じ関数に違う数の引数を指定した関数とかを、一つの演算子に適用する感じ。
{-# LANGUAGE GADTs #-}
{-# LANGUAGE FlexibleInstances #-}
module Main where
data Seq where
Seq :: (Sequensable a, Sequensable b) => a -> b -> Seq
data Note = Note { fromNote :: Int } deriving Show
a :: Int -> Int -> Note
a x y = Note $ x + y
@tokiwoousaka
tokiwoousaka / gist:9d196f154b5cd689f4b7
Created March 10, 2015 13:26
undefinedを埋めてく感じでシンセ毎に機能を作っていく感じになるはず https://github.com/tokiwoousaka/ArareDSL/blob/master/src/Sound/Arare/ArareDSL.hs ただし事実上フレーズの多相化みたいな事は難しいっぽい。
{-# LANGUAGE FlexibleInstances #-}
module Main where
import Sound.Arare.ArareDSL
data SinOscillator
instance NoteController SinOscillator where
noteOn = undefined
noteOff = undefined
@tokiwoousaka
tokiwoousaka / gist:82a4c9ab5027af1e0264
Last active August 29, 2015 14:17
Haskellでオブジェクト指向の実験
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE GADTs #-}
module Main where
import Control.Applicative
import Control.Monad.Identity
import Control.Monad.State
import Control.Concurrent.MVar
import Control.Monad.Operational
--------
@tokiwoousaka
tokiwoousaka / gist:b1d8fe96137b3ae3a122
Last active August 29, 2015 14:17
objectiveを用いた継承
{-# LANGUAGE GADTs #-}
module Main where
import Control.Object
import Control.Monad.Operational
import Control.Monad.Trans.State.Strict
import Control.Monad.IO.Class
import Control.Monad
main :: IO ()
main = do