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 DeriveFunctor #-} | |
{-# LANGUAGE DeriveFoldable #-} | |
-- uses packages: comonad-transformers,streams,MonadRandom | |
import Prelude hiding (iterate,tail,repeat,sequence,take,zip,unzip) | |
import Data.Stream.Infinite (Stream ((:>)),iterate,tail,repeat,take,zip,unzip,unfold) | |
import Data.Foldable | |
import Data.Traversable (Traversable(..), sequence) | |
import Control.Applicative |
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.Tree | |
import Control.Comonad | |
import Control.Comonad.Trans.Class | |
import Control.Comonad.Trans.Env | |
replusify:: MonadPlus m => [a] -> m a | |
replusify = msum . map return | |
class Treeish l where | |
children :: MonadPlus m => l -> m l |
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.Functor.Identity | |
import Control.Applicative | |
import Control.Monad | |
import Control.Monad.Trans | |
import Control.Monad.Trans.Maybe | |
-- From the monad-loops package | |
import Control.Monad.Loops | |
import Data.Void | |
import Data.Conduit | |
import Data.Conduit.List |
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
pairs l = [ [(i,j) | j <- l] | i <- l] | |
pairs' l = do | |
i <- l | |
return $ do | |
j <- l | |
return (i,j) |
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
# This is a class. | |
# | |
# http://rdoc.rubyforge.org/RDoc/Markup.html | |
class Foo | |
# This is a method | |
# | |
# = This is a header | |
# | |
# This is below the header | |
# |
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 KindSignatures #-} | |
import Control.Monad | |
import Control.Monad.Trans | |
import Control.Monad.Trans.Maybe | |
import Control.Applicative | |
import Data.Functor.Compose | |
--newtype Constant a (b:: * -> *) = Constant { getConstant :: a } | |
newtype Constant a (b:: * -> *) = Constant { getConstant :: 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
{-# LANGUAGE KindSignatures #-} | |
-- http://stackoverflow.com/questions/12717301/haskell-type-synonym-declaration-with-constraint-possible | |
{-# LANGUAGE Rank2Types #-} -- Necessary for the type synonyms to work!!!! | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE GeneralizedNewtypeDeriving #-} | |
import Data.Functor.Compose | |
import Data.Monoid | |
--import Control.Category |
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
// from here http://stackoverflow.com/questions/1094173/how-do-i-get-around-type-erasure-on-scala-or-why-cant-i-get-the-type-paramete | |
List(1,2,3) match { | |
case l : List[String] => println("A list of strings?!") | |
case _ => println("Ok") | |
} | |
// <console>:9: warning: fruitless type test: a value of type List[Int] cannot also be a List[String] (but still might match its erasure) | |
// case l : List[String] => println("A list of strings?!") |
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
(dotimes [i 10] (.start (new Thread (fn [] (println i))))) | |
(dotimes [i 10] (.start (Thread. (fn [] (println i))))) |
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
currfile = nil | |
File.open("postgresql.dmp", "r") do |file_handle| | |
file_handle.each_line do |line| | |
if line =~ /^COPY (\S+) / | |
currfile.close unless currfile.nil? | |
currfile = File.open("./postgresql_parts/#{$1}.dmp","w") | |
end | |
currfile.puts(line) unless currfile.nil? | |
end | |
end |
OlderNewer