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 { BehaviorSubject, Observable, IDisposable } from 'rx'; | |
/** | |
* Behavior represents a value that varies in time. | |
* Behavior is similar to `BehaviorSubject` because it always has value, | |
* but it's not `Subject`, that is you can't push values into it whenever you want. | |
* You can only subscribe it to an Observable once. | |
*/ | |
export class Behavior<T> implements IDisposable { | |
/** Create a behavior that never changes. */ |
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
/** | |
* The Maybe type encapsulates an optional value. | |
*/ | |
export class Maybe<T> { | |
/** Create an empty value. */ | |
static nothing<T>(): Maybe<T> { | |
return new Maybe<T>(undefined); | |
} | |
/** Create a non-empty value. */ |
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 | |
TypeInType | |
, ExplicitForAll | |
, ScopedTypeVariables | |
, RecursiveDo | |
, TypeApplications | |
, TemplateHaskell | |
, FlexibleInstances | |
, MultiParamTypeClasses | |
, TypeFamilies |
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 BangPatterns #-} | |
module Main where | |
import qualified Data.Text as Text | |
import Data.Text (Text, pack) | |
import Criterion.Main | |
import Test.QuickCheck.Arbitrary | |
import Test.QuickCheck | |
import Data.List | |
import qualified Data.Vector.Unboxed as U |
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
{-# OPTIONS_GHC -Wall -fno-warn-unused-binds #-} | |
{-# LANGUAGE CPP #-} | |
{-# LANGUAGE FlexibleContexts #-} | |
{-# LANGUAGE IncoherentInstances #-} | |
{-# LANGUAGE RankNTypes #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
#if __GLASGOW_HASKELL__ >= 708 | |
{-# LANGUAGE RoleAnnotations #-} | |
#endif |
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 UnboxedTuples, MagicHash, TypeFamilies, DataKinds, PolyKinds, TypeOperators, DefaultSignatures #-} | |
{-# LANGUAGE KindSignatures, FlexibleInstances, FlexibleContexts #-} | |
{-# LANGUAGE DeriveGeneric, DeriveAnyClass #-} | |
module Data.Unboxed where | |
import GHC.Exts | |
import GHC.Generics | |