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 Data.Char | |
| import Data.Functor | |
| import Data.List | |
| import Data.Maybe | |
| import Data.Set (Set, fromList, member) | |
| import System.Environment | |
| import System.Exit |
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/runhaskell | |
| import Control.Category ((>>>)) | |
| import Data.Function | |
| import Data.Functor | |
| import Data.List | |
| import System.Environment | |
| import System.Info |
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 TemplateHaskell #-} | |
| module NiceDebug where | |
| import Debug.Trace | |
| import Language.Haskell.TH | |
| import Language.Haskell.TH.Instances | |
| debug :: Name -> Q Exp |
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
| #!/bin/bash | |
| bundle exec rspec & | |
| trap ' | |
| kill -INT $! | |
| kill -INT $! | |
| wait | |
| echo | |
| ' INT | |
| wait |
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
| -- Compile with `ghc -threaded -with-rtsopts=-N concurrent_sieve.hs` | |
| import Control.Concurrent | |
| import Control.Monad | |
| import System.Environment | |
| generate :: MVar Int -> IO () | |
| generate mOut = mapM_ (putMVar mOut) [2..] |
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 DataKinds | |
| , GADTs | |
| , KindSignatures | |
| , StandaloneDeriving | |
| , TypeOperators | |
| #-} | |
| -- | A list type with statically determined length encoded in its type | |
| -- | |
| -- Requires GHC 7.6.1 or greater. |
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
| POEM: <LINE> <LINE> <LINE> <LINE> <LINE> | |
| LINE: <NOUN>|<PREPOSITION>|<PRONOUN> $LINEBREAK | |
| ADJECTIVE: black|white|dark|light|bright|murky|muddy|clear <NOUN>|<ADJECTIVE>|$END | |
| NOUN: heart|sun|moon|thunder|fire|time|wind|sea|river|flavor|wave|willow|rain|tree|flower|field|meadow|pasture|harvest|water|father|mother|brother|sister <VERB>|<PREPOSITION>|$END | |
| PRONOUN: my|your|his|her <NOUN>|<ADJECTIVE> | |
| VERB: runs|walks|stands|climbs|crawls|flows|flies|transcends|ascends|descends|sinks <PREPOSITION>|<PRONOUN>|$END | |
| PREPOSITION: above|across|against|along|among|around|before|behind|beneath|beside|between|beyond|during|inside|onto|outside|under|underneath|upon|with|without|through <NOUN>|<PRONOUN>|<ADJECTIVE> |
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 FlexibleInstances | |
| , MultiParamTypeClasses | |
| , TemplateHaskell | |
| , TypeSynonymInstances #-} | |
| {-# OPTIONS_GHC -fno-warn-orphans #-} | |
| import Prelude hiding (print) | |
| import AdvancedOverlap |
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
| {- | |
| - Count how many numbers with no repeated digits lie between 1 and the | |
| - specified maximum (given as a command line argument) | |
| - | |
| - For instance 183957 is counted, while 298387 is not ('8' occurs twice). | |
| - | |
| - On SMP systems, parallelism is exploited to speed up the computation | |
| - significantly. The search space is divided into as many evenly-sized chunks | |
| - as the host system has cores, and worker threads are spawned to run on each | |
| - core. This small program is primarily intended to illustrate the usage of |
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 TemplateHaskell #-} | |
| module THOp (mkOps) where | |
| import Control.Monad | |
| import Language.Haskell.TH | |
| mkOp :: String -> Q [Dec] | |
| mkOp n = [| $(varE a) + $(varE b) + length (filter (=='-') n) |] >>= \body -> |