Skip to content

Instantly share code, notes, and snippets.

View khibino's full-sized avatar

日比野 啓 (Kei Hibino) khibino

View GitHub Profile
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE FlexibleInstances #-}
module Position where
import GHC.Generics (Generic)
import Foreign.Ptr (Ptr )
import Data.Word (Word8)
Debian sid 上の groonga 8.0.2 および Debian jessie 上の groonga 8.0.1 で実験しました。
groonga に投入するクライアントプログラムを中断すると、
それとは関係のない別のクライアントで、JSON の解釈エラーが返ることがある問題があるようです。
問題を再現するスクリプト run.sh を作ることに成功したのでここに貼ります。
( 後輩の前角さんが協力してくれました。ありがとうございます。 )
実行に必要な Debian package は、
groonga, curl です。
run.sh を実行すると、
@khibino
khibino / name-config.hs
Created March 19, 2018 03:00
Name configuration example of Haskell Relational Record
import Language.Haskell.TH (nameBase)
import Language.Haskell.TH.Name.CamelCase (varCamelcaseName, varName)
import Database.Record.TH
customConfig :: NameConfig
customConfig =
defaultNameConfig
{ columnName = \tbl col -> varCamelcaseName $ tbl ++ "_" ++ col }
main :: IO ()
module ExplicitDict where
-- explicit type class definition
data Mon m =
Mon
{ mon_op :: m -> m -> m
, mon_unit :: m
}
-- monoid instance of (*, 1)
auto lxc-br
iface lxc-br inet static
address 172.23.0.1/16
## OUI of PEGATRON CORPORATION is 60:02:92
## lower two bits of first octet is
## Global - 0 / Local - 1 bit and Individual - 0 / Group - 1 bit,
## so 60 + 2 + 0 == 62
bridge_ports none
bridge_hw 62:02:92:11:11:01
bridge_maxwait 0
type Parser a = String -> [(a, String)]
return_ :: a -> Parser a
return_ v = \inp -> [(v, inp)]
failure :: Parser a
failure = \inp -> []
item = \inp -> case inp of
[] -> []
take' :: Int -> [a] -> [a]
take' n _
| n <= 0 = []
take' _ [] = []
take' n (x:xs) = x : take' (n - 1) xs -- 先に整数値で場合分け, トップレベルで pattern match
take'2 n xxs
| n <= 0 = []
| otherwise = case xxs of
[] -> []
@khibino
khibino / j.hs
Last active June 29, 2016 12:22
import Control.Applicative
import Control.Monad
import Data.Monoid
import Control.Monad.Trans.Except
data Exception
= IOException String
| NoSuchElementException
deriving Show
import Prelude hiding (sum)
data L1
= F { ($$) :: L1 -> L1 }
| V { unV :: Int }
infixl 1 $$
instance Show L1 where
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
module Model where
import Data.Int (Int32)
import Data.Time