This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ 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, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 @>>>@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# 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 } |