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 OverloadedStrings #-} | |
import Control.Applicative | |
import Data.Aeson | |
import Data.Monoid | |
import Data.Maybe | |
data Quto = Quto (Maybe Int) (Maybe String) deriving Show | |
-- Парсер поддерживающий отсуствие значений | |
instance FromJSON Quto where |
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
-- | | |
-- Types and instances of anonymous records. | |
{-# LANGUAGE TypeOperators #-} | |
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE KindSignatures #-} | |
{-# LANGUAGE MultiParamTypeClasses #-} | |
{-# LANGUAGE Rank2Types #-} | |
{-# LANGUAGE UndecidableInstances #-} | |
{-# LANGUAGE FlexibleInstances #-} |
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 TemplateHaskell, StandaloneDeriving, MultiParamTypeClasses, TypeFamilies, GeneralizedNewtypeDeriving #-} | |
import Control.Monad | |
import Control.Concurrent | |
import Control.Distributed.Process | |
import Control.Distributed.Process.Backend.SimpleLocalnet | |
import Control.Distributed.Process.Closure | |
import Control.Distributed.Process.Internal.Types (Process(..), LocalProcess) | |
import Control.Distributed.Process.Node (initRemoteTable) | |
import Control.Monad.Base (MonadBase(..)) |
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 Sort a = SortI a '[] | |
type family SortI a b where | |
SortI '[] b = b | |
SortI (a:?n ': as) '[] = SortI as '[ a :? n] | |
SortI (a:?n ': as) bs = SortI as (Insert (a:?n) bs) | |
type family Insert a b where | |
Insert (a :? n) '[] = '[ a :? n ] | |
Insert (a :? n) ( b :? m ': bs) = UnOrdering (CmpSymbol n m) |
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.Char (ord) | |
import Data.Conduit | |
import Data.Conduit.Binary (sourceHandle, sinkHandle) | |
import qualified Data.Conduit.Binary as CB | |
import qualified Data.Conduit.List as CL | |
import qualified Data.ByteString as S | |
import qualified Data.ByteString.Char8 as S8 | |
import qualified Data.ByteString.Lazy as SL | |
import System.Environment (getArgs) | |
import System.IO |
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 PackageImports #-} | |
import Data.Binary.Get | |
import "mtl" Control.Monad.Writer | |
import qualified Data.ByteString.Lazy as SL | |
import Data.Word | |
main = do | |
l <- SL.readFile "test" | |
let (a,b) = runWriter $ next l 0 | |
print 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
{-# LANGUAGE PackageImports, TypeFamilies, FlexibleContexts #-} | |
-- code experiments with using monad stack with conduit | |
-- it works well except one case - using ResourceT in inner | |
-- monad (commented out function) | |
import Data.Conduit | |
import Data.Conduit.Network | |
import "mtl" Control.Monad.Reader | |
import "mtl" Control.Monad.Writer |
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
{-# OPTIONS -Wall #-} | |
import Data.Conduit | |
import Data.Conduit.Network | |
import Control.Monad.IO.Class (liftIO) | |
import Control.Monad.Trans.Resource | |
import Control.Concurrent.Lifted (fork) | |
import Control.Concurrent (killThread) | |
main::IO () | |
main = |
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
{-# GHC_OPTIONS -O2 -Wall #-} | |
{-# LANGUAGE BangPatterns #-} | |
import System.IO | |
import Data.Word | |
import Data.Char (ord) | |
import Data.Array.Unboxed | |
import Data.Array.ST | |
import Data.ByteString.Lazy (ByteString) |
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.Concurrent.STM | |
import Control.Concurrent.STM.TVar | |
import Control.Concurrent.STM.TChan | |
import Data.Map (Map) | |
import qualified Data.Map as Map | |
reglock = newTMVar | |
registry = newTVar empty | |
addProcess :: (a -> IO ()) -> TVar c -> b -> IO () |