Skip to content

Instantly share code, notes, and snippets.

View khibino's full-sized avatar

日比野 啓 (Kei Hibino) khibino

View GitHub Profile
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
import Prelude hiding (id, (.))
import Control.Category (Category(..))
import Data.Monoid (Monoid(..))
newtype F a b = F (a -> b) deriving Category
instance Monoid (F a a) where
{-# LANGUAGE FlexibleInstances #-}
import Prelude hiding (id, (.))
import qualified Prelude
import Control.Category (Category(..))
import Data.Monoid (Monoid(..))
newtype F a b = F (a -> b)
instance Category F where
{-# LANGUAGE FlexibleInstances #-}
import Prelude hiding (id, (.))
import Control.Category (Category(..))
import Data.Monoid (Monoid(..))
instance Category cat => Monoid (cat a a) where
mempty = id
mappend = (.)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
int
main (int argc, char *argv[]) {
char buf[1048576];
char obuf[1048576];
int i;
import Data.List (isPrefixOf)
import Data.Set (Set)
import qualified Data.Set as Set
data K' = K0 | K1
deriving (Show, Eq, Ord)
data K = Unit K'
| Str !String
deriving Show
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE IncoherentInstances #-}
module X where
data P a = P
flattenMaybe :: P (Maybe (Maybe a)) -> P (Maybe a)
{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses, TypeOperators #-}
module Monoid where
import Data.Monoid (Monoid, Sum, Product)
import qualified Data.Monoid as M
import Control.Category
class Category (-->) => CategoricalMonoid (-->) m where
mempty :: m
@khibino
khibino / gist:6228874
Last active September 16, 2017 03:49
{-# LANGUAGE GADTs #-}
{-# LANGUAGE MultiParamTypeClasses #-}
data WithZero
data WithoutZero
data Exp a where
ExpZero :: Exp WithZero
ExpOne :: Exp WithoutZero
@khibino
khibino / gist:8295770
Last active September 16, 2017 03:41
{-# LANGUAGE TemplateHaskell, MultiParamTypeClasses, FlexibleInstances, OverloadedStrings #-}
import Data.Int (Int64)
import Database.HDBC.PostgreSQL (connectPostgreSQL)
import Database.HDBC.Schema.PostgreSQL (driverPostgreSQL)
import Database.HDBC.Query.TH (defineTableFromDB)
import Database.Relational.Query
$(defineTableFromDB
(connectPostgreSQL "dbname=testdb")
import MyTuple
import Control.Applicative
import Database.Record
import Database.Record.ToSql
import Database.Relational.Query
import Database.HDBC (SqlValue)
import Database.HDBC.Query.TH
instance ProductConstructor (a -> b -> c -> MyTuple a b c) where