Skip to content

Instantly share code, notes, and snippets.

src/Control/Proxy/Trans/Parse.hs:138:30:
Could not deduce (e ~ ReadParserError)
from the context (Read b)
bound by the instance declaration
at src/Control/Proxy/Trans/Parse.hs:132:10-41
`e' is a rigid type variable bound by
the type signature for parse :: ReadParser b -> a -> Result e a b1
at src/Control/Proxy/Trans/Parse.hs:137:3
In the second argument of `Fail', namely `e'
In the expression: Fail a' e
@k0001
k0001 / Parse.hs
Last active December 10, 2015 15:18
Control.Proxy.Trans.Parse
{ # LANGUAGE GeneralizedNewtypeDeriving #-}
module Control.Proxy.Trans.Parse (
-- * ParseP
ParseP(..),
runParseP,
runParseK
) where
import Control.Applicative (Applicative)
{ # LANGUAGE OverloadedStrings #-}
module Main where
import qualified RFC2616
import Control.Applicative
import Control.Monad
import Control.Proxy ((>->), request, respond, lift)
import qualified Control.Proxy as P
import qualified Control.Proxy.Attoparsec as PA
@k0001
k0001 / gist:4410640
Last active December 10, 2015 08:58
Playing with pipes-bytestring, pipes-attoparsec, and aeson
{-# LANGUAGE NoMonomorphismRestriction #-}
module Main where
import Control.Applicative
import Control.Proxy
import qualified Data.ByteString.Internal as BS
import qualified Data.ByteString.Lazy as BL
import qualified Data.ByteString.Lazy as BLI
import qualified Control.Proxy.Attoparsec as PA
import Control.Monad.Instances
import Control.Monad.Reader
data Env = Env Int Int
foo :: Int -> Env -> Int
foo a (Env x _) = a + x
- switch (state) {
+ switch (state) { /** Finit tillståndsmaskinen från helvete **/
@k0001
k0001 / constcheatshit.c
Created April 19, 2012 16:53
C const rules cheat shit
typedef struct {
int a;
const int b;
} thing_t;
int main(int argc, char *argv[])
{
thing_t t1 = { .a = 1, .b = 2 };
t1.a = 90;
// t1.b = 90; // NO!
module Tony20 (
Fluffy,
furry,
EitherLeft(..),
EitherRight(..),
Misty,
banana,
unicorn,
jellybean,
apple
ghci> "Hello World" =~ "W.rld" :: Bool
True
ghci> "Hello World" =~ "W.rld" :: Int
1
ghci> "Hello World" =~ "W.rld" :: String
"World"
ghci> "Hello World" =~ "W.rld" :: (Int, Int)
(6,5)
@k0001
k0001 / groupBy.hs
Created January 2, 2012 09:21
My (untested) implementation of Data.List.groupBy
-- My (untested) implementation of Data.List.groupBy
groupBy' :: (a -> a -> Bool) -> [a] -> [[a]]
groupBy' f xs = foldr step [] xs
where step x acc@(yy@(y:ys):yys)
| f x y = (x:yy):yys
| otherwise = [x]:acc
step x [] = [[x]]