Skip to content

Instantly share code, notes, and snippets.

@myuon
myuon / End.hs
Created August 2, 2013 13:51
とりあえず書いてみたところまで(結局endまで出来てない)
{-# LANGUAGE GADTs, RankNTypes, MultiParamTypeClasses, FlexibleInstances #-}
module End where
import qualified Prelude
import Control.Category
import Data.Monoid
import Data.Functor.Identity
type Hask = (->)
@myuon
myuon / makeClassy.hs
Last active December 21, 2015 18:39
makeClassyを使って複数のオブジェクトで共通する函数をまとめる
{-# LANGUAGE TemplateHaskell, FlexibleContexts, FlexibleInstances, UndecidableInstances, OverlappingInstances #-}
import Control.Lens
import Control.Monad.State
-- 基本となるオブジェクト
data Obj = Obj {
_pos :: Int
} deriving (Show)
-- Obj型のオブジェクトをもつ抽象的なクラスHasObjを作る
{-# LANGUAGE ImplicitParams, BangPatterns #-}
-----------------------------------------------------------------------------
-- |
-- Module : Graphics.UI.FreeGame.GUI.GLFW
-- Copyright : (C) 2013 Fumiaki Kinoshita
-- License : BSD-style (see the file LICENSE)
--
-- Maintainer : Fumiaki Kinoshita <[email protected]>
-- Stability : experimental
-- Portability : non-portable
@myuon
myuon / otsukare.py
Last active December 26, 2015 17:19
maletterプラグイン(cf.https://github.com/myuon/maletter) plugin/以下に保存して起動
#!/usr/bin/env python
#-*- coding:utf-8 -*-
import sys
import os
sys.path.append(os.pardir)
from PyQt4 import QtGui, QtCore
import datetime
#! /usr/bin/python3.3
#-*- coding:utf-8 -*-
import matplotlib.pyplot as plt
import numpy as np
import random
from timeit import Timer
import time
def recur(n, x, func):
@myuon
myuon / 0_reuse_code.js
Created November 11, 2013 02:05
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
Mon Nov 18 00:40 2013 Time and Allocation Profiling Report (Final)
Main +RTS -p -RTS
total time = 9.97 secs (9968 ticks @ 1000 us, 1 processor)
total alloc = 304,891,560 bytes (excludes profiling overheads)
COST CENTRE MODULE %time %alloc
update Chimera.STG 69.7 2.0
@myuon
myuon / file0.hs
Created November 27, 2013 09:24
GCがパフォーマンス低下を引き起こす? ref: http://qiita.com/myuon_myon/items/1eb2dabc71ff33a8e572
{-# LANGUAGE TemplateHaskell #-}
import System.Environment
import Control.Monad.State
import Control.Lens
data Obj = Obj { _pos :: (Integer, Integer) } deriving Show
makeLenses ''Obj
benchmark1 :: [Obj] -> IO [Obj]
benchmark1 g = mapM (\e -> update `execStateT` e) g
@myuon
myuon / file0.hs
Created December 4, 2013 14:21
同じ型を持つオブジェクトの実装を変えられるようにしたい ref: http://qiita.com/myuon_myon/items/38dc54565a37597ecf7e
{-# LANGUAGE TemplateHaskell, TypeSynonymInstances, FlexibleInstances #-}
import Control.Monad.State
import Control.Lens
import Data.Functor.Identity
data Autonomie m a = Autonomie { auto :: a, runAuto :: m () }
class Game c where
update :: State c ()
draw :: StateT c IO ()
@myuon
myuon / file0.hs
Created December 31, 2013 11:43
extensible-effectsのReader, Writer, Stateを試してみる ref: http://qiita.com/myuon_myon/items/a172ed5d765b4385d974
{-# LANGUAGE FlexibleContexts, DeriveDataTypeable #-}
import Control.Eff
import Control.Eff.Reader.Lazy
import Control.Eff.State.Lazy
import Control.Eff.Writer.Lazy
import Data.Typeable (Typeable)
import Control.Monad
type Task = String
newtype Worker = Worker { todo :: [Task] }