Skip to content

Instantly share code, notes, and snippets.

View konn's full-sized avatar
🏠
Working from home

Hiromi Ishii konn

🏠
Working from home
View GitHub Profile
{-# LANGUAGE TemplateHaskell #-}
module Macro where
import SList
import Language.Haskell.TH
import Language.Haskell.TH.Quote
import Data.Generics
listToSList :: (Data a) => [a] -> ExpQ
listToSList [] = conE 'Nil
listToSList xs = do
{-# LANGUAGE TypeFamilies, GADTs, EmptyDataDecls, TypeOperators,
UndecidableInstances, MultiParamTypeClasses, FunctionalDependencies,
ScopedTypeVariables, FlexibleInstances, FlexibleContexts #-}
module Dependent where
data Z
data S a
zero :: Z
zero = undefined
{-# Language PackageImports #-}
import Text.Parsec
import Control.Applicative hiding ((<|>), many)
import Control.Monad
import Control.Monad.Trans (liftIO)
import Control.Monad.State
import Data.Word
import System.IO
import System.Environment
prop_split :: String -> String -> Bool
prop_split x xs = xs == intercalate x (split x xs)
split :: Eq a => [a] -> [a] -> [[a]]
split [] xs = map (:[]) xs
split sep [] = []
split sep xs = unfoldr step (Just xs)
where
step Nothing = Nothing
step (Just xs) = flip mplus (Just (xs, Nothing)) $ do
{-# LANGUAGE GADTs, TypeFamilies #-}
data GExpr a where
GInt :: Int -> GExpr Int
GPlus :: GExpr Int -> GExpr Int -> GExpr Int
GMult :: GExpr Int -> GExpr Int -> GExpr Int
GChar :: Char -> GExpr Char
GList :: [GExpr a] -> GExpr [a]
evalG :: GExpr a -> a
{-# LANGUAGE TemplateHaskell #-}
import InfTree
main = print $(infTree)
@konn
konn / Kind.hs
Created September 23, 2010 14:38
type S f g x = f x (g x)
type K a b = a
type I a = a
num :: S K K Int
num = 12
main = print num
@konn
konn / llist.c
Created September 25, 2010 04:13
#include <stdio.h>
#include <stdlib.h>
struct llist{
int var;
struct llist *next;
};
struct llist array_to_llist(int size, int *array) {
struct llist hoge[size];
import Control.Arrow
import Control.Arrow.CoKleisli
import Control.Comonad
import Control.Comonad.Reader
import Data.Array
import Control.Comonad.Pointer
import Control.Functor.Extras
import Data.Monoid
import Control.Comonad.Exponent
import Control.Comonad.Stream
@konn
konn / All.dat
Created November 4, 2010 14:40
GHCExtensions.dat
TemplateHaskell: 70
DeriveDataTypeable: 41
OverloadedStrings: 40
FlexibleInstances: 37
TypeSynonymInstances: 31
ScopedTypeVariables: 30
TypeOperators: 30
NamedFieldPuns: 26
FlexibleContexts: 25
PackageImports: 25