Skip to content

Instantly share code, notes, and snippets.

/* FNV-1 hash
*
* The FNV-1 hash description: http://isthe.com/chongo/tech/comp/fnv/
* The FNV-1 hash is public domain: http://isthe.com/chongo/tech/comp/fnv/#public_domain
long hashable_fnv_hash(const unsigned char* str, long len, long hash) {
while (len--) {
hash = (hash * 16777619) ^ *str++;
}
> modifyMatch :: LMatch RdrName (LHsExpr RdrName)
> -> LMatch RdrName (LHsExpr RdrName)
> modifyMatch (L l1 (Match lpat lty rs@(GRHSs{..}))) =
> let f (L l1 (GRHS guards body)) =
> L l1 (GRHS guards (modifyExpr body))
> in L l1 (Match lpat lty (rs
> { grhssGRHSs = map f grhssGRHSs }))
instance (a ~ D.SVG, b ~ D.R2, c ~ Any) => Display (D.QDiagram a b c) where
instance Display (D.QDiagram D.SVG D.R2 Any) where
src/Diagrams/Trail.hs:150:1:
Can't make a derived instance of `Transformable (SegTree v)'
(even with cunning newtype deriving):
it is not type-safe to use GeneralizedNewtypeDeriving on this class;
the last parameter of `Transformable' is at role N
In the stand-alone deriving instance for
`(HasLinearMap v, InnerSpace v, OrderedField (Scalar v)) =>
Transformable (SegTree v)'
match "gallery/*.lhs" $ version "gallery" $ do
route $ setExtension "html"
compile $ do
getResourceBody >>= saveSnapshot "rawcontent"
withMathJax
>>= loadAndApplyTemplate "templates/exampleHi.html"
( mconcat
[ field "code" readSource
, setImgURL
, setHtmlURL
@co-dan
co-dan / FAlgebra.hs
Created August 11, 2013 12:56
F-algebras
{-# LANGUAGE DeriveFunctor #-}
module FAlgebra where
-- General types
newtype Algebra f a = Alg { unAlg :: (f a -> a) }
newtype Mu f = Fix (f (Mu f))
-- Dummy expression type/functor
data ExprF a = Const Int
@co-dan
co-dan / Main.hs
Last active December 19, 2015 20:49
Working on scotty-hastache
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Text.Hastache
import Web.Scotty as S
import Web.Scotty.Hastache
main :: IO ()
main = scottyH' 3000 $ do
setTemplatesDir "/home/vagrant/dev/"
proxy1 :: (Proxy p) => String -> Server p String Int IO ()
proxy1 = fromListS [1..] >-> mapU (const ()) >-> useU putStrLn
retpmorp :: (Proxy p) => () -> p String () () C IO r
retpmorp () = turn $ prompter ()
prompter :: (Proxy p) => () -> Producer p String IO r
prompter () = runIdentityP $ forever $ do
lift $ putStr "> "
lift $ hFlush stdout
file { '/home/vagrant/stage1_cabalsrc.sh':
ensure => present,
source => "/vagrant/scripts/stage1_cabalsrc.sh",
owner => vagrant,
mode => 766
}
~>
exec { 'build1':
provider => 'shell',
user => vagrant,
@co-dan
co-dan / Main.hs
Last active December 18, 2015 00:49
import Language.Haskell.Interpreter
import MyModule
main = do
r <- runInterpreter interp
case r of
Left err -> print $ show err
Right res -> print res
interp :: Interpreter IntBox