learning… haskell math how generators work in python french how to draw an instrument
  
    
      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.Applicative | |
| data Thread a = Stop a | Go (IO (Thread a)) | |
| instance Functor Thread where | |
| fmap f (Stop a) = Stop (f a) | |
| fmap f (Go g) = Go $ g >>= return . fmap f | |
| instance Applicative Thread where | |
| pure = Stop | 
  
    
      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
    
  
  
    
  | newtype State s a = State { runState :: s -> (a, s) } | |
| instance Functor (State s) where | |
| fmap f (State g) = State $ \s -> | |
| let (a, s') = g s | |
| in (f a, s') | |
| instance Applicative (State s) where | |
| pure x = State $ \s -> (x, s) | |
| (<*>) = ap | 
  
    
      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 Trie where | |
| import Prelude hiding (insert, lookup) | |
| import Data.Maybe (fromJust) | |
| import qualified Data.Map as M | |
| data Trie = Trie Bool (M.Map Char Trie) | |
| empty :: Trie | |
| empty = Trie False M.empty | 
  
    
      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 Parser where | |
| import Prelude hiding (or, take) | |
| import qualified Prelude | |
| import Control.Applicative (Applicative(..)) | |
| import qualified Control.Applicative as A | |
| import Control.Monad (ap) | |
| import Data.Char | 
  
    
      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 java.net.InetSocketAddress | |
| import scala.concurrent.Task | |
| import scalaz.stream._ | |
| object Main { | |
| def main(args: Array[String]): Unit = { | |
| val address = new InetSocketAddress(45678) | |
| implicit val cg = nio.DefaultAsynchronousChannelGroup | |
| val s: Process[Task, Process[Task, Unit]] = nio.server(address).map { client => | |
| client.flatMap { ex => | 
  
    
      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 java.nio.ByteBuffer | |
| import java.nio.channels.{AsynchronousServerSocketChannel, AsynchronousSocketChannel} | |
| import scala.concurrent.{Future, Promise} | |
| object Nio { | |
| def accept(server: AsynchronousServerSocketChannel): Future[AsynchronousSocketChannel] = { | |
| val p = Promise[AsynchronousSocketChannel] | |
| server.accept(null, new CompletionHandler[AsynchronousSocketChannel, Void] { | |
| def completed(client: AsynchronousSocketChannel, attachment: Void) = p.success(client) | |
| def failed(e: Throwable, attachment: Void) = p.failure(e) | 
  
    
      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 Bst | |
| ( | |
| T -- type is left abstract | |
| , empty | |
| , insert | |
| , contains | |
| , ofList | |
| , toList | |
| ) where | 
  
    
      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
    
  
  
    
  | open Core.Std | |
| type 'a tree = Mt | Node of 'a tree * 'a * 'a tree | |
| type ('a, 'cmp) t = { comparator : ('a, 'cmp) Comparator.t; | |
| data : 'a tree } | |
| let empty ~comparator = { comparator; data = Mt } | |
| let insert t a = | |
| let rec helper data a = | 
  
    
      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
    
  
  
    
  | open Core.Std | |
| module type Equalizer = sig | |
| type ('a, 'eq) t = private { equal : 'a -> 'a -> bool } | |
| module Make (A : Equal.S) : sig | |
| type eq | |
| val t : (A.t, eq) t | |
| end | |
| end |