Skip to content

Instantly share code, notes, and snippets.

@akihiro4chawon
akihiro4chawon / KOPC12D.hs
Created February 3, 2012 17:26
FFI修行の末、私も非行に走る
{-# OPTIONS_GHC -XForeignFunctionInterface #-}
{-# OPTIONS_GHC -O2 -optc-O2 #-}
module Main where
import Foreign
import Foreign.C
import System.IO
foreign import ccall unsafe "stdio.h &fdopen"
@akihiro4chawon
akihiro4chawon / WinMain.hs
Created January 29, 2012 07:25
FFI力養成訓練の結果(産廃)
{-# LANGUAGE ForeignFunctionInterface #-}
module Main where
import Foreign
import Control.Exception (bracket)
import Control.Monad
import Control.Monad.Cont ()
import Data.Maybe
import Graphics.Win32 hiding (moveWindow, c_MoveWindow) -- param type should be INT, not Int
Arrow を見ていると多幸感がございますな。。。
とりあえず Haskell & Arrow の勉強のため、恒等変換探索機を作ってみたが、
まだまだルールベースが全然足りていない。。。
@akihiro4chawon
akihiro4chawon / _KenArrowLoopFib.scala
Created January 6, 2012 12:46
Ken が凄すぎる。。。
import com.github.okomok.ken
object ArrowLoopFib extends ken.Main {
import ken._
import List.{tail, zipWith}
import Tuple2.snd
val fibSeqFrom = locally {
// use Function Arrow in this environment
import Function.{app, loop, &&&:, ***:, <<<:, >>>:}
import com.github.akihiro4chawon.arm.arrow._
import scalaz._
import Scalaz._
object Main extends App {
import java.io._
// なんの変哲もない部分
def copyStream(is: InputStream, os: OutputStream, buffSize: Int) {
val buff = new Array[Byte](buffSize)
import com.github.akihiro4chawon.arm._
import scalaz._
import Scalaz._
object Main extends App {
import java.io._
// なんの変哲もない部分
def copyStream(is: InputStream, os: OutputStream, buffSize: Int) {
val buff = new Array[Byte](buffSize)
@akihiro4chawon
akihiro4chawon / Main.hs
Created December 20, 2011 10:46
functional heap
import Control.Applicative
import Control.Arrow(first)
import Control.Monad
import Data.Map (Map)
import qualified Data.Map as Map
import Data.Maybe
import Data.Monoid
import Data.Function
import MyHeap
@akihiro4chawon
akihiro4chawon / PE250.hs
Created November 18, 2011 07:18
こういうことだろうか?
{-# LANGUAGE BangPatterns #-}
{-# OPTIONS_GHC -Wall -O2 #-}
import Control.Arrow((***))
import Control.Monad(ap, join)
import Control.Monad.Instances()
import Data.List(foldl', genericLength, genericReplicate, genericSplitAt)
import Data.Function(on)
--
@akihiro4chawon
akihiro4chawon / PE250.hs
Created November 18, 2011 06:27
富豪 Haskeller 矯正ギプス (2) - 剰余類
{-# LANGUAGE BangPatterns #-}
{-# OPTIONS_GHC -Wall -O2 #-}
import Control.Arrow((***))
import Control.Monad(ap, join)
import Control.Monad.Instances()
import Data.List(foldl', genericLength, genericReplicate, genericSplitAt)
import Data.Function(on)
newtype Modulo = Modulo { getInteger :: Integer}
@akihiro4chawon
akihiro4chawon / PE250.hs
Created November 18, 2011 06:06
お漏らし Haskeller 矯正ギプス (1) - zipWith
{-# LANGUAGE BangPatterns #-}
{-# OPTIONS_GHC -Wall -O2 #-}
-- 使用例
import Control.Monad(ap, join)
import Control.Monad.Instances()
import Data.List(foldl', genericLength, genericReplicate, genericSplitAt)
-- 結局 bang pattern を使うように書き直しているっていう。。。