Skip to content

Instantly share code, notes, and snippets.


Dan Frumin co-dan

  • Groningen / Gensokyo (not yet)
View GitHub Profile
co-dan / gist:c874b9624ef09399a2c7
Last active Dec 17, 2017
Yoneda lemma for fmap fusion
View gist:c874b9624ef09399a2c7
-- Yoneda lemma
newtype Yoneda f a =
Yoneda (forall b. (a -> b) -> f b)
-- Nat (Hom(a, -), F) ~~ F a
-- this is `liftYoneda`
yoneda :: (Functor f) => f a -> Yoneda f a
yoneda x = Yoneda $ \f -> fmap f x
co-dan / SeqFoldable.hs
Created Apr 7, 2014
View SeqFoldable.hs
{-# LANGUAGE TypeFamilies, FlexibleInstances #-}
module SeqFoldable where
import Prelude hiding (drop, take)
import Data.Functor.Foldable
import Data.Sequence (Seq, ViewL (..), (<|))
import qualified Data.Sequence as S
co-dan / .zshrc
Last active Dec 31, 2015
Cabal sandbox status in your ZSH prompt
View .zshrc
# This simple script displays whether you are in a cabal sandbox
# the the result of checking for a sandbox is cached, but now that I
# actually think about it, it was probably an unnecessary step.
# Don't forget to customize the PROMPT variable at the bottom
# Looks like this with my prompt:
function update_cabal_sandbox_info () {
View gist:7945382
Resolving dependencies...
Configuring diagrams-contrib-
Building diagrams-contrib-
Preprocessing library diagrams-contrib-
warning: missing terminating ' character [-Winvalid-pp-token]
-- Instead of using Doubles, which can't be compared for equality, it
View interactive.hs
{-# LANGUAGE TypeFamilies,
FunctionalDependencies #-}
import Control.Concurrent
import Control.Monad
import Control.Monad.Fix
import JavaScript.JQuery
View hashable.js
/* FNV-1 hash
* The FNV-1 hash description:
* The FNV-1 hash is public domain:
long hashable_fnv_hash(const unsigned char* str, long len, long hash) {
while (len--) {
hash = (hash * 16777619) ^ *str++;
View gist:6356964
> 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 }))
View gist:6351495
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
View error
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)'
View gist:6233372
match "gallery/*.lhs" $ version "gallery" $ do
route $ setExtension "html"
compile $ do
getResourceBody >>= saveSnapshot "rawcontent"
>>= loadAndApplyTemplate "templates/exampleHi.html"
( mconcat
[ field "code" readSource
, setImgURL
, setHtmlURL
You can’t perform that action at this time.