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 #-} | |
import Streaming | |
import Streaming.Prelude (each, next, yield) | |
import qualified Data.ByteString.Streaming.Char8 as Q | |
import qualified Data.ByteString.Char8 as B | |
import qualified Streaming.Prelude as S | |
import qualified Control.Foldl as L | |
import Data.ByteString.Streaming.HTTP -- git clone https://github.com/michaelt/streaming-http | |
-- cabal install ./streaming-http | |
infixl 5 >>>; (>>>) = flip (.) |
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
-- These examples are based on the tutorial module in the io-streams package | |
{-#LANGUAGE OverloadedStrings #-} | |
import Streaming | |
import Streaming.Prelude (yield, next, each, for, with, subst) | |
import qualified Streaming.Prelude as S | |
import qualified Data.ByteString.Char8 as B | |
import Data.ByteString.Streaming (ByteString) | |
import qualified Data.ByteString.Streaming.Char8 as Q | |
import System.IO (withFile, IOMode(..)) |
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
#!/bin/bash | |
# Build, export, and publish the Nix dependencies of an Aurora job. | |
# Then use the aurora commandline utility to launch it. | |
# | |
# This should really be an Aurora client hook, or at least a | |
# better-integrated wrapper script. | |
set -e | |
attr=${1:?USAGE: $0 <attribute>} | |
shift |
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
{-# 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 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 NoMonomorphismRestriction #-} | |
{-# LANGUAGE TemplateHaskell #-} | |
{-# OPTIONS_GHC -fwarn-missing-methods #-} | |
module Err where | |
import Control.Lens | |
import Control.Monad.Error | |
import Control.Monad.Error.Lens | |
-- Here is a fairly typical situation, where we have low level errors in certain |
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 #-} | |
module Main where | |
import Control.Lens -- lens | |
import Control.Monad.IO.Class -- transformers | |
import Control.Monad.Trans.AWS -- amazonka | |
import Network.AWS.EC2 -- amazonka-ec2 | |
main :: 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
> import Control.Monad.Trans | |
> import Control.Monad.Trans.Iter | |
The completely iterative free monad transformer lets us capture non-termination as an effect. Furthermore, it's a monad *transformer*, so we can add non-termination on top of other effects. | |
A convenient combinator is | |
> untilSuccess :: Monad m => m (Maybe a) -> IterT m a | |
> untilSuccess f = maybe (delay (untilSuccess f)) return =<< lift f |
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
enum Either<A, B> { | |
case Left(A) | |
case Right(B) | |
} | |
func isLeft<A,B>(it : Either<A,B>) -> Bool { | |
switch it { case .Left: return true; case .Right: return false } | |
} | |
func isRight<A,B>(it : Either<A,B>) -> Bool { |
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
// Taken from the commercial iOS PDF framework http://pspdfkit.com. | |
// Copyright (c) 2014 Peter Steinberger, PSPDFKit GmbH. All rights reserved. | |
// Licensed under MIT (http://opensource.org/licenses/MIT) | |
// | |
// You should only use this in debug builds. It doesn't use private API, but I wouldn't ship it. | |
// PLEASE DUPE rdar://27192338 (https://openradar.appspot.com/27192338) if you would like to see this in UIKit. | |
#import <objc/runtime.h> | |
#import <objc/message.h> |
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
#!/usr/bin/env runhaskell | |
-- Synopsis: | |
-- $ cabal install QuickCheck | |
-- $ runhaskell io_quickcheck_example.hs | |
-- | |
-- Author: Issac Trotts <[email protected]> | |
import Directory | |
import System.Environment |