Skip to content

Instantly share code, notes, and snippets.

View fumieval's full-sized avatar
🐦
Birb

Fumiaki Kinoshita fumieval

🐦
Birb
View GitHub Profile
{-# LANGUAGE DataKinds, TypeOperators, KindSignatures, GADTs, StandaloneDeriving, ScopedTypeVariables, Rank2Types, PolyKinds, DeriveTraversable #-}
import Unsafe.Coerce
import GHC.TypeLits
import Data.Type.Equality
import Data.Proxy
import Prelude hiding (drop)
import Data.Foldable
data Tree :: Nat -> Nat -> * -> * where
Bin :: a -> Tree i j a -> Tree j k a -> Tree k (1 + j + k) a
@fumieval
fumieval / arr.hs
Last active August 27, 2015 02:08
import qualified Data.Vector as V
import qualified Data.Vector.Generic as G
import qualified Data.Vector.Fusion.Bundle as Bundle
newtype Arr a = Arr [V.Vector a]
(<|) :: a -> Arr a -> Arr a
a <| Arr (v:w:xs)
| V.length v == V.length w = Arr (G.unstream (Bundle.cons a $ G.stream v Bundle.++ G.stream w) : xs)
a <| Arr xs = Arr (V.singleton a : xs)
data Pos a = Rel !a | Abs !a deriving (Show, Read, Eq, Ord, Functor)
instance Num a => Monoid (Pos a) where
mempty = Rel 0
_ `mappend` Abs a = Abs a
Abs a `mappend` Rel b = Abs (a + b)
Rel a `mappend` Rel b = Rel (a + b)
{-# LANGUAGE FlexibleContexts #-}
module Flyweight where
import Data.Functor.Rep
import qualified Data.HashMap.Strict as HM
import System.Random
import Control.Concurrent
import Data.Hashable
import System.Mem.Weak
data I a = I { hashI :: Int, contentI :: a } deriving Show
{-# LANGUAGE DeriveFunctor #-}
module Voxel where
import BurningPrelude
import qualified Data.HashMap.Strict as Map
import qualified Data.Set as Set
import qualified Data.Vector as V
import Util
import Data.Witherable
import Control.DeepSeq
import Data.Bits
@fumieval
fumieval / FBX.hs
Created April 28, 2015 07:50
FBX 7.4 parser
{-# LANGUAGE LambdaCase, TypeFamilies, DataKinds, TypeOperators, FlexibleContexts, OverloadedStrings, StandaloneDeriving #-}
module Codec.Container.FBX where
import qualified Data.Vector.Unboxed as UV
import Data.Binary
import Data.Binary.Get
import Data.Binary.Put
import Data.Int
import Data.ByteString (ByteString)
import qualified Data.ByteString as BS
{-# LANGUAGE TypeOperators, DataKinds, FlexibleContexts, FlexibleInstances, UndecidableInstances, PolyKinds, TemplateHaskell #-}
import Data.Aeson (FromJSON(..), withObject)
import Data.Extensible (Record, Field(..), KeyValue, AssocKey, Forall, hgenerateFor)
import GHC.TypeLits (KnownSymbol, symbolVal)
import Data.Proxy
import Data.String (fromString)
import qualified Data.HashMap.Strict as HM
keyProxy :: proxy kv -> Proxy (AssocKey kv)
keyProxy _ = Proxy
$ pacman -S liblzma
$ pacman -S liblzma-devel
$ git clone https://github.com/maoe/lzma
$ cd lzma
$ cabal configure --extra-include-dirs=C:\msys64\usr\include --extra-lib-dirs=C:\msys64\usr\lib
$ cabal build
Building lzma-0.0.0...
Preprocessing library lzma-0.0.0...
In file included from C:\msys64\usr\include/inttypes.h:14:0,
from C:\msys64\usr\include/lzma.h:116,
import Control.Object
echo' :: Object f (Coyoneda f)
echo' = Object $ Coyoneda (\x -> (x, echo'))
(@>>>@) :: Object f (Coyoneda g) -> Object g (Coyoneda h) -> Object f (Coyoneda h)
Object m @>>>@ Object n = Object $ \f -> case m f of
Coyoneda k g -> case n g of
Coyoneda l h -> Coyoneda (\x -> case l x of (y, ogh) -> case k y of (z, ofg) -> (z, ofg @>>>@ ogh)) h
infixr 1 @>>>@
{-# LANGUAGE Rank2Types #-}
import qualified Data.IntMap as IM
import Data.IORef
import Control.Monad.Writer
import Data.Foldable as F
import Data.Monoid
import Control.Applicative
import Control.Lens
newtype Builder a m = Builder { unBuilder :: forall r. (a -> m r) -> m r }