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
{- compile with -fdefer-type-errors -} | |
import Control.Exception | |
import Data.List | |
import System.IO.Unsafe | |
assertTypeError :: a -> () | |
assertTypeError a = unsafePerformIO $ do | |
res <- try $ evaluate a | |
case res of Left e@(ErrorCall msg) -> if "expected type" `isInfixOf` msg |
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 | |
import Control.Monad.ST | |
import Data.Array.MArray | |
import Data.Array.ST | |
swap :: STArray s Int a -> Int -> Int -> ST s () | |
swap ar i j = do | |
ei <- readArray ar i | |
ej <- readArray ar j | |
writeArray ar i ej |
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
%default total | |
data T : Type where | |
A : T | |
B : T | |
my_neg : T -> T | |
my_neg A = B | |
my_neg B = A |
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 Data.Ratio ((%)) | |
import GHC.Real | |
-- 10 decimal places | |
newtype Fixed = Fixed Integer deriving (Eq, Ord, Enum) | |
instance Show Fixed where | |
show (Fixed a) = show whole ++ "." ++ trailing where | |
(whole, part) = a `divMod` (10 ^ 10) | |
digits = show part |
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
-----> Self-updating bashmenot... done, ac791c3 | |
-----> Self-updating Halcyon... done, a0894ef | |
-----> Examining cache contents | |
cabal-install-1.22.0.0.tar.gz | |
ghc-7.10.0.20150316-x86_64-unknown-linux-deb7.tar.xz | |
halcyon-build-snowflake-0.1.1.1.tar.gz | |
halcyon-cabal-1.20.0.3-hackage-2015-03-17.tar.gz | |
halcyon-ghc-7.8.4.tar.gz | |
halcyon-ghc-7.10.1-rc3.tar.gz | |
halcyon-install-b188d5d-snowflake-0.1.1.1.tar.gz |
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
module Main where | |
data Stream a = Stream a (Stream a) deriving (Eq, Show, Functor) | |
data Zipper a = Zipper { zl :: (Stream a) | |
, ze :: a | |
, zr :: (Stream a) | |
} deriving (Eq, Show, Functor) | |
srepeat :: a -> Stream a | |
srepeat a = go where go = Stream a go |
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
module Main where | |
import Control.Concurrent | |
import Control.Monad | |
import System.Environment (getArgs) | |
main = do | |
[n,m] <- getArgs | |
let slots = [1..read n] | |
vars <- forM slots $ const newEmptyMVar |
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
module Main where | |
import Control.Monad (when, replicateM) | |
import Control.Monad.IO.Class (liftIO) | |
import qualified Data.ByteString as BS | |
import qualified Blaze.ByteString.Builder as B | |
import qualified Network.HTTP.Client as C | |
import Web.Scotty | |
chunkSize = 32 * 1024 |
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
module TypedMap | |
( TypedMap | |
, empty | |
, insert | |
, lookup | |
) where | |
import Data.Dynamic | |
import Data.Maybe (fromJust) | |
import qualified Data.Map as M |
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
package main | |
import ( | |
"flag" | |
"fmt" | |
"io/ioutil" | |
"os" | |
"os/exec" | |
) |