Skip to content

Instantly share code, notes, and snippets.

View jvranish's full-sized avatar

Job Vranish jvranish

  • Grand Rapids, MI
View GitHub Profile
module Main where
import System.Environment
l v = f (reverse v) - 1
where
f ([]) = 0
f (x:xs) = (nmap x + 1) + baseLen * f xs
nmap x = fromJust $ lookup x $ zip base [0..]
base = ['a'..'z']
import Data.Maybe
-- The fixed point datatype
data Y f = Y (f (Y f))
-- dummy function for illustration
maybeToInt :: Maybe a -> Int
maybeToInt = length . maybeToList
{-# LANGUAGE MagicHash, UnboxedTuples, Rank2Types, FlexibleInstances,
MultiParamTypeClasses, UndecidableInstances #-}
{- |
Module : Control.Monad.ST.Trans
Copyright : Josef Svenningsson 2008
(c) The University of Glasgow, 1994-2000
License : BSD
Maintainer : [email protected]
Stability : experimental
import Control.Monad.State
import Data.Word
import Data.Bits
-- maybe make this an operator?
getField :: (Bits a) => a -> a -> a
getField value mask = flip evalState (mask, value, 0) $ do
sequence $ replicate (bitSize value) (get >>= setMaskBit)
(_, _, result) <- get
return result
{-# LANGUAGE GeneralizedNewtypeDeriving, RankNTypes, RecursiveDo #-}
module ContextRefHidden
( ContextRef
, Context
, runContext
, newRef
, readRef
, writeRef
, refKey
, attempt
class GameTcpSocket : public QTcpSocket
{
const int timeout = 2 * 1000;
GameTcpSocket(QObject* parent = 0) : QTcpSocket(parent)
{
}
template<class T> GameTcpSocket& operator<< (T data)
{
QByteArray block;
module Main where
import Control.Monad
import Data.IORef
--import Debug.Trace
import System.Mem.Weak
import qualified Data.Map as M
import Prelude hiding (lookup)
{-# LANGUAGE FlexibleContexts #-}
module Main where
import Language.Gator hiding (sequence, mapM)
import Data.FixedList
import qualified Data.FixedList
import Control.Applicative
import Data.Traversable
import Prelude hiding (sequence, mapM)
import Control.Applicative
import Control.Monad
import Data.Foldable
import Data.Traversable
import Data.Monoid
import Data.Maybe
import Prelude hiding (head, tail)
import Data.Tree
import Data.Traversable
import Control.Monad.State hiding (mapM)
import Prelude hiding (mapM)
test :: (Tree Integer, Integer)
test = markOrdering (Node undefined [Node undefined [Node undefined []], Node undefined []]) 0
markOrdering :: (Num t1) => Tree t -> t1 -> (Tree t1, t1)