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 Data.Function | |
import Control.Monad | |
data M m a = M a | |
instance Monad (M m) where | |
return = M | |
(M a) >>= f = f 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
type IsoKey = Int | |
-- | Serialized element | |
data ElementS = ElementS Int [IsoKey] | |
data Element = Element Int [Isotope] deriving (Show) | |
data Isotope = Isotope IsoKey Element deriving (Show) -- payload | |
to :: [ElementS] -> [Element] | |
to es = let result = map (\(ElementS z keys) -> Element z (map (\k -> Isotope k (un help k)) keys)) es | |
help = zip es result |
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
main = withSocketsDo $ | |
eventChan <- newChan | |
tm <- newTimerIO | |
forever $ | |
bracket (createNetwork tm chan) | |
(threadKill) $ waitTimer tm >> resetTimer tm | |
where | |
createNet tm chan = bracket (connect) (sClose) (network tm chan) | |
connect = do | |
addrinfos <- getAddrInfo Nothing (Just "") (Just "3000") |
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.Monad.State (StateT) | |
import qualified Control.Monad.State as State | |
import Data.Map (Map) | |
import qualified Data.Map as Map | |
import Data.IORef (IORef) | |
import qualified Data.IORef as IORef | |
data AbstractKVS m k v = AbstractKVS | |
{ kvsPut :: k -> v -> m () | |
, kvsGet :: k -> m (Maybe v) |
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 KindSignatures #-} | |
{-# LANGUAGE GADTs #-} | |
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE TemplateHaskell #-} | |
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE Rank2Types #-} | |
{-# LANGUAGE MultiParamTypeClasses #-} | |
{-# LANGUAGE FunctionalDependencies #-} |
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 KindSignatures #-} | |
{-# LANGUAGE GADTs #-} | |
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE TemplateHaskell #-} | |
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE Rank2Types #-} | |
{-# LANGUAGE MultiParamTypeClasses #-} | |
{-# LANGUAGE FunctionalDependencies #-} |
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
### Keybase proof | |
I hereby claim: | |
* I am qnikst on github. | |
* I am qnikst (https://keybase.io/qnikst) on keybase. | |
* I have a public key whose fingerprint is 15B0 78F1 9761 860B A04A 4263 7651 2BBA 09DD 3D53 | |
To claim this, I am signing this object: |
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 BangPatterns #-} | |
import Control.Applicative | |
import Prelude hiding (minimum, sum) | |
import Data.List (permutations) | |
import Control.Monad.ST | |
import Data.Bifunctor (second) | |
-- import Control.Monad | |
-- import Data.Array.ST | |
-- import Data.Array.Unboxed | |
import Data.Vector.Unboxed (Vector) |
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 Data.List | |
import Control.Monad.ST | |
import Control.Monad | |
import Data.Array.ST | |
import Data.Array.Unboxed | |
data Exp = IfGt Int Int Block Block -- if a[i] > a[j] then blk1 else blk2 | |
| Swap Int Int -- a[i] <-> a[j] (i,j < 8) | |
| Copy Int Int -- a[i] <- a[j] (i > 7) | |
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 MultiParamTypeClasses #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE FlexibleContexts #-} | |
{-# LANGUAGE DefaultSignatures #-} | |
module TaggedPut where | |
import Data.Binary (Binary) | |
import qualified Data.Binary as Binary | |
import Data.ByteString.Lazy |
OlderNewer