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 #-} | |
module DeriveADT | |
( deriveExtract | |
, deriveIs | |
) where | |
import Data.Maybe | |
import Data.Char | |
import Language.Haskell.TH |
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
-- | |
-- xmonad example config file. | |
-- | |
-- A template showing all available configuration hooks, | |
-- and how to override the defaults in your own xmonad.hs conf file. | |
-- | |
-- Normally, you'd only override those defaults you care about. | |
-- | |
import System.Exit | |
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
-- | how to make a function that is based on its return type? | |
class (Storable a) => P a where | |
data Ps a | |
pStorageType :: [a] -> StorageType | |
wP :: [a] -> (Ptr a -> IO b) -> IO b | |
wP xs f = V.unsafeWith (V.fromList xs) f | |
export:: (MonadIO m, Pixel a) => PMagickWand -> Int -> m [a] | |
exportImagePixels len = exportArray len ffiFunction undefined |
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.Default | |
import Debug.Trace | |
class Magick a where | |
magickStorage :: [a] -> String | |
instance Magick Int where | |
magickStorage = const "Int" | |
instance Magick Char 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
{-# LANGUAGE OverloadedStrings, FlexibleContexts, RankNTypes, KindSignatures #-} | |
module Main | |
where | |
import Prelude hiding (FilePath) | |
import Data.ByteString as S | |
import Data.ByteString.Lazy as SL | |
import Data.ByteString.Lazy.Char8 as SL8 |
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
I have a distributed network that consists of a equal nodes. | |
I have 2 types of messages: | |
Events: | |
Each node can send a stream of events corresponding to concrete "structure" | |
All nodes can subscribe to events for list of "structures" | |
Commands: | |
Each node can send a commands to concrete node. | |
Responses to commands should be asynchronous. |
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.Function | |
import Data.List | |
import Control.Monad | |
import Debug.Trace | |
import Data.Set (Set) | |
import qualified Data.Set as S | |
type History = [Int] | |
type Mouse = Int | |
type Size = Int |
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
-- картинка http://postimg.org/image/wyxmmdo5v/ | |
import Data.List | |
import Data.DList (singleton, fromList, snoc, empty, toList) | |
import Control.Monad.Trans.Writer.Lazy | |
import Criterion.Main | |
import Data.Maybe | |
zipMore :: [a] -> [b] -> ([(a,b)],[a],[b]) | |
zipMore [] xs = ([],[],xs) | |
zipMore xs [] = ([],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
{-# LANGUAGE BangPatterns #-} | |
module Main where | |
import qualified Data.ByteString as BS | |
import System.IO | |
import Control.Monad | |
import Data.Bits | |
import Data.Word | |
import Data.Monoid | |
import Network.Openflow.StrictPut |
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
-- Vector: | |
icsum16 :: Word32 -> V.Vector Word16 -> Word32 | |
icsum16 !i bv = V.foldl' (\a -> (+a).fromIntegral) i bv | |
{-# INLINE icsum16 #-} | |
icsum16 :: Word32 -> Vector Word16 -> Word32 | |
icsum16 = | |
\ (eta :: Word32) (eta1 :: Vector Word16) -> | |
let { Vector ipv ipv1 ipv2 ~ _ <- eta1 } in |