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
cat | grep foo | |
{ cat aabsdf.xx 2>&1 ; } 2>/dev/null | |
# http://stackoverflow.com/questions/2342826/how-to-pipe-stderr-and-not-stdout?rq=1 | |
# http://www.gnu.org/software/bash/manual/bashref.html#Redirections | |
# http://mywiki.wooledge.org/Redirection |
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
object Foo { | |
def main(args: Array[String]):Unit = { | |
println("jaaaaaar") | |
args.foreach(println) | |
args.foreach(println(_)) | |
args.foreach((s:String)=>println(s)) | |
val listy = List(2,3,4,5) | |
val x = listy match { | |
case _ => "whatever" |
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
scala> val s = Set(3,5,6) | |
s: scala.collection.immutable.Set[Int] = Set(3, 5, 6) | |
scala> List(34,234,5,6,3).map(s) | |
res3: List[Boolean] = List(false, false, true, true, true) | |
scala> List(34,234,5,6,3)(2) | |
res4: Int = 5 |
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
-- Fails with Control.Monad.State.Strict | |
-- Works with Control.Monad.State.Lazy | |
evalState (undefined >> put 'a' >> get ) 'c' | |
-- See on SO: http://stackoverflow.com/questions/13186512/difference-between-haskells-lazy-and-strict-monads-or-transformers |
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
-- | Main entry point to the application. | |
module Main where | |
import qualified Data.Vector.Unboxed as V | |
import Control.Monad | |
import Control.Monad.Random | |
import System.Random | |
foovec :: V.Vector Int |
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
spcs ps = skipSpace *> foldr (*>) skipSpace (intersperse skipSpace ps) |
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
parseKeywords = manyTill' (takeTill isEndOfLine *> endOfLine) | |
(_string "wt.contentGroup" *> _char '=' *> _char '{') | |
*> sepBy' (_skipMany1 digit *> _char ':' *> _parseQuot) | |
(_char ',') | |
where _string x = skipSpace *> string x | |
_char x = skipSpace *> char x | |
_skipMany1 x = skipSpace *> skipMany1 x | |
_parseQuot = _char '"' *> A.takeWhile isAlpha <* char '"' |
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.List | |
import Control.Monad.Trans.Writer | |
import Control.Applicative | |
import Data.Functor.Compose | |
import Data.Monoid | |
tell' :: Monoid a => a -> Compose [] (Writer a) () | |
tell' = Compose . pure . tell | |
list :: Monoid a => [x] -> Compose [] (Writer a) x |
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 FlexibleContexts #-} | |
{-# LANGUAGE OverloadedStrings #-} | |
{-# LANGUAGE TemplateHaskell #-} | |
{-# LANGUAGE RankNTypes #-} | |
module Main where | |
import System.IO | |
import Control.Applicative | |
import Control.Monad |
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 TemplateHaskell #-} | |
{-# LANGUAGE OverloadedStrings #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
import Control.Lens | |
import System.IO | |
-- Note that data constructors can't begin with underscore _ | |
data Foo = A Int Int | B Char Char | |
makePrisms ''Foo |