This file contains hidden or 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.ByteString as BS | |
| import qualified Data.ByteString.Internal as BS (c2w, w2c) | |
| import Data.Enumerator hiding (head) | |
| import qualified Data.Enumerator.Binary as EB | |
| import qualified Data.Enumerator.List as EL | |
| import System.Environment | |
| countLines :: Iteratee BS.ByteString IO Int | |
| countLines = do | |
| bs <- EL.head |
This file contains hidden or 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
| -- From A tutorial on the enumerator library | |
| -- http://www.mew.org/~kazu/proj/enumerator/ | |
| import Control.Applicative | |
| import Control.Monad | |
| import Control.Monad.IO.Class | |
| import Data.Enumerator hiding (map, filter, filterM) | |
| import qualified Data.Enumerator.List as EL | |
| import Data.List | |
| import System.Directory | |
| import System.FilePath |
This file contains hidden or 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
| module CombinatorParser where | |
| import Control.Monad | |
| import Data.Char | |
| -- FUNCTIONAL PEARLS: Monadic Parsing in Haskell | |
| -- http://eprints.nottingham.ac.uk/223/1/pearl.pdf | |
| newtype Parser a = Parser { parse :: (String -> [(a, String)]) } |
This file contains hidden or 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 | |
| import Control.Monad.ST | |
| import Data.Array.MArray | |
| import Data.Array.ST | |
| import Data.STRef | |
| import Prelude hiding (id) | |
| data UnionFind s = UnionFind { | |
| ids:: STUArray s Int Int |
This file contains hidden or 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
| module IntMap where | |
| import Data.Bits | |
| import Prelude hiding (lookup) | |
| -- Fast Mergeable lnteger Maps* | |
| -- http://ittc.ku.edu/~andygill/papers/IntMap98.pdf | |
| -- Little-endian implementation | |
| type Key = Int |
This file contains hidden or 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
| #! /usr/bin/env ocamlscript | |
| Ocaml.ocamlflags := ["-thread"]; | |
| Ocaml.packs := [ "core" ] | |
| -- | |
| open Core.Std | |
| type term = | |
| | Ident of string | |
| | Lambda of string * term | |
| | Apply of term * term |
This file contains hidden or 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 EmptyDataDecls #-} | |
| module Hello where | |
| import FFI | |
| data Http | |
| data HttpServer | |
| data Request | |
| data Response |
This file contains hidden or 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
| using System; | |
| namespace Option | |
| { | |
| public abstract class Option<T> | |
| { | |
| public abstract T Value { get; } | |
| public abstract bool IsSome { get; } |
This file contains hidden or 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
| class Reduce t where | |
| reducer :: (a -> b -> b) -> (t a -> b -> b) | |
| reducel :: (b -> a -> b) -> (b -> t a -> b) | |
| instance Reduce [] where | |
| reducer f x z = foldr f z x | |
| reducel f x z = foldl f x z | |
| toList :: (Reduce f) => f a -> [a] | |
| toList s = s `cons` [] where cons = reducer (:) |
This file contains hidden or 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.Maybe | |
| ssfold :: (a -> Bool) -> (a -> b -> a) -> a -> [b] -> a | |
| ssfold p f a0 xs = foldr (\x xs a -> if p a then a else xs (f a x)) id xs a0 |
OlderNewer