Skip to content

Instantly share code, notes, and snippets.

@yuga
yuga / realTimeDeque.ml
Created August 6, 2012 05:25
An implementation of Real-Time Deques in PFDS (Chapter 8.4.3)
module type ITEM =
sig
type t
val print : t -> unit
end
module type ORDERED =
sig
include ITEM
@yuga
yuga / hsc2hs-ghc-7.4.1.patch
Created August 20, 2012 05:57
Quick Fix to solve runProcess error of hsc2hs
diff -Naru hsc2hs-ghc-7.4.1/utils/hsc2hs/Common.hs hsc2hs-ghc-7.4.1-fixed/utils/hsc2hs/Common.hs
--- hsc2hs-ghc-7.4.1/utils/hsc2hs/Common.hs 2012-02-02 03:10:32.000000000 +0900
+++ hsc2hs-ghc-7.4.1-fixed/utils/hsc2hs/Common.hs 2012-08-20 12:30:18.350942900 +0900
@@ -24,7 +24,11 @@
splitName :: String -> (String, String)
splitName name =
+#if defined(mingw32_HOST_OS)
+ case break (== '\\') name of
+#else
@yuga
yuga / gist:3522778
Created August 30, 2012 05:28
Data.Binary.Strict.BitGet starts to read bit from the position having the greatest value of a byte.
$ ghci
GHCi, version 7.4.1: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Prelude> import Data.Binary.Strict.BitGet
Prelude Data.Binary.Strict.BitGet> import Data.ByteString
Prelude Data.Binary.Strict.BitGet Data.ByteString> let a = pack [0x80,0x00]
Loading package bytestring-0.9.2.1 ... linking ... done.
Prelude Data.Binary.Strict.BitGet Data.ByteString> let r = runBitGet a $ getBit
@yuga
yuga / ex0910_LazyBinaryRandomAccessList.ml
Created September 30, 2012 00:59
a solution to Exercise 9.10 of "Purely Functional Data Structures (PFDS)"
(* a solution to Exercise 9.10 of "Purely Functional Data Structures (PFDS)" *)
module type ITEM =
sig
type t
val print : t -> unit
end
module Int : (ITEM with type t = int) =
struct
@yuga
yuga / ex0901_BinaryRandomAccessList.ml
Created September 30, 2012 15:19
a solution to Exercise 9.1 of "Purely Functional Data Structures (PFDS)"
(* a solution to Exercise 9.1 of "Purely Functional Data Structures (PFDS)" *)
module type ITEM =
sig
type t
val print : t -> unit
end
module Int : (ITEM with type t = int) =
struct
@yuga
yuga / gist:3909984
Created October 18, 2012 05:19
GHCがpinned objectをどのようにGCで回収するか

山本和彦 ?@kazu_yamamoto 教えて詳しい人:GHC では ByteString が pinned object なんですが、どうやって GC に回収されるんでしょうか?

詳しくはないけど、ざっと追いかけてみる。

GHC 7.4.1 rts/sm/Storage.c:743

// If we don't have a block of pinned objects yet, or the current

// one isn't large enough to hold the new object, allocate a new one.

@yuga
yuga / gist:4087259
Created November 16, 2012 13:13
Windowsでregex-pcre-builtinのビルドに失敗するときの対処法

Windowsでregex-pcre-builtinのビルドに失敗するときの対処法

Windowsにpandocをインストールするとかするとはまります。

依存関係: pandoc -> highlighting-kate -> regex-pcre-builtin

regex-pcre-builtin-0.94.4.1.8.31 用の手順です。

エラー事象

@yuga
yuga / gist:4094702
Created November 17, 2012 10:22
How to fix the failure of building regex-pcre-builtin on Windows

How to fix the failure of building regex-pcre-builtin on Windows

Q. What is the issue?

A. Let's do the clean installation of pandoc on Windows. Cabal tell us that something went wrong

>cabal install regex-pcre-builtin

Resolving dependencies...

@yuga
yuga / MinPrint.hs
Created December 12, 2012 13:03
HaskellでMonad使ったDSL書く練習 #1 未テスト
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE OverloadedStrings #-}
module MinPrint (
MinPrint, Doc,
text, br, nest,
execMinPrint, printDoc
) where
import qualified Data.ByteString.Char8 as S
@yuga
yuga / cabal.md
Last active October 20, 2015 09:54
Cabal-1.20.0.2 を使ってビルドしたcabal-installだとcabal testで標準出力が文字化けする。

Cabal-1.20.0.2 を使ってビルドしたcabal-installだとcabal testで標準出力が文字化けする。 Cabal-1.20.0.3 でも修正されていない。1.22系にしか入っていない模様。