Skip to content

Instantly share code, notes, and snippets.

View Davorak's full-sized avatar

Patrick Wheeler Davorak

View GitHub Profile
{-# language GeneralizedNewtypeDeriving #-}
import Control.DeepSeq
import HLearn.Algebra
import HLearn.Models.Distributions
iBag = [1..5] ++ [1..5] ++ [5..10]
newtype IG = IG Int
deriving (Read,Show, Num)
@Davorak
Davorak / Main.hs
Last active August 29, 2015 14:01
import qualified Data.Text.Lazy as T
import qualified Data.Foldable as F
import Control.Monad (when)
import Control.Monad.Trans.Class
import qualified Control.Monad.Trans.Maybe as M
-- import Control.Monad.Morph
{-
{- | File "tmp2" fails to close in this example
- ghci> runSafeT . runEffect $ readFile' "tmp" >-> writeFile' "tmp2"
- {tmp2 open}
- {tmp open}
- {tmp closed}
-}
{-# language RankNTypes #-}
{-# language NoMonomorphismRestriction #-}
@Davorak
Davorak / hdph-streaming-test.hs
Created April 22, 2014 03:25
Full example of non-determinism while streaming with GIVars in HdpH
{-# LANGUAGE TemplateHaskell #-}
{-# language RankNTypes #-}
-- {-# LANGUAGE NoMonomorphismRestriction #-}
-- {-# LANGUAGE DeriveDataTypeable #-}
-- {-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE IncoherentInstances #-}
@Davorak
Davorak / gist:5691906
Last active December 17, 2015 23:49
Steaming resumable coordinate parsing with pipes-parse.
import Control.Proxy
import Control.Proxy.Trans.State
import Control.Proxy.Parse
import Control.Monad
coordinate = liftP . pull -- Could be more complex with needing its own buffer
-- type and failure mechanisms
@Davorak
Davorak / examples.hs
Last active December 17, 2015 23:48
Examples of resumable parsers with pipes-parse a Haskell package. Each example explains its purpose in the comments above it.
import Control.Proxy
import Control.Proxy.Trans.State
import Control.Proxy.Parse
import Control.Monad
chunkLine'
:: (Monad m, Proxy p) =>
() -> StateP [Char] p () (Maybe Char) a [Char] m ()
article
aside
blockquote
body
br
button
canvas
caption
col
colgroup
ghc -fforce-recomp --make Main.hs -rtsopts -O2
@Davorak
Davorak / Explanation.md
Last active December 15, 2015 03:09
Below is example code for nixpkgs issue: https://github.com/NixOS/nixpkgs/issues/395 This is a one line modification of the example code provided in the hint package: http://darcsden.com/jcpetruzza/hint/browse/examples

line 20 of example.hs was:

setImportsQ [("Prelude", Nothing), ("Data.Map", Just "M")]

for this example it is:

setImportsQ [("Prelude", Nothing), ("Data.Map", Just "M"), ("Control.Proxy", Just "P")]

When run with runhaskell or compiled with ghc hint can not find the pipes package when it is install through nix.