Skip to content

Instantly share code, notes, and snippets.

View bitemyapp's full-sized avatar
🐺
aroo

Chris A. bitemyapp

🐺
aroo
View GitHub Profile
@erewok
erewok / Main.hs
Last active November 10, 2015 03:37
Moving Average Test: Uses Conduits
{-# LANGUAGE MultiWayIf #-}
module Main where
import Control.Monad.IO.Class (liftIO)
import Data.Conduit (($$), (=$=), (=$)
, Conduit, Sink, Source
, await, yield)
import qualified Data.Conduit.List as CL
import Data.Sequence
@ali-abrar
ali-abrar / index.html
Last active June 8, 2020 04:47
Setting up Leaflet.js with Reflex.Dom
<!DOCTYPE html>
<html>
<head>
<!-- Add leaflet css -->
<link
rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css"
integrity="sha512-xwE/Az9zrjBIphAcBb3F6JVqxf46+CDLwfLMHloNu6KEQCAWi6HcDUbeOfBIptF7tcCzusKFjFw2yuvEpDL9wQ=="
crossorigin=""
/>
  1. Don't use partial functions (head, read, tail, fromJust, fail (in IO), error, undefined ... )
  2. Functions are your friend, use lots of them and keep them small.
  3. Serialization errors are the most common error in our codebase. When you are creating a JSON, Binary or Serialize instance try and avoid the standard "generator" functions.
@raichoo
raichoo / Codensity.idr
Created September 11, 2015 19:13
List Codensity transformation in Idris
module Main
data Free : (f : Type -> Type) -> (a : Type) -> Type where
Pure : a -> Free f a
Bind : f (Free f a) -> Free f a
instance Functor f => Functor (Free f) where
map f (Pure x) = Pure (f x)
map f (Bind x) = assert_total (Bind (map (map f) x))
  1. General Background and Overview
@chrisdotcode
chrisdotcode / Promise.hs
Created February 16, 2015 00:07
Abstract Promises in Haskell
module Promise where
import Control.Applicative (Applicative(..))
import Data.Monoid (Monoid(..))
newtype Error = Error { unString :: String } deriving (Eq, Ord, Read, Show)
data Promise a = Failed Error | Deferred | Fulfilled a
deriving (Eq, Ord, Read, Show)
@tonymorris
tonymorris / condenscension-police.md
Last active August 29, 2015 14:15
The Condenscension Police

CAUTION: this rant has not been proof-read to any extent at all

The condenscension police are here, with their double-standards and unquestionable claim to a moral high-ground. Persistently engaged in disgusting conduct, I ask, "do they ever look at themselves?"

I know the answer to this question. I tested it. At one point in time, I was concerned that the charge directed at me had merit. Were they right? Were they a bit wrong, but mostly right? I wanted to know the answer to this question. No, I really really wanted to know it. So I invested some effort toward answering

@tonymorris
tonymorris / functor.hs
Created February 9, 2015 01:44
Higher-kinds and type-classes are distinct concepts.
{-# LANGUAGE RankNTypes #-}
module Functor where
import Prelude(
foldr
, (.)
, Maybe(Nothing, Just)
, maybe
)
@nkpart
nkpart / Err.hs
Last active August 20, 2022 01:20
Lens, Prisms, and Errors.
{-# LANGUAGE NoMonomorphismRestriction #-}
{-# LANGUAGE TemplateHaskell #-}
{-# OPTIONS_GHC -fwarn-missing-methods #-}
module Err where
import Control.Lens
import Control.Monad.Error
import Control.Monad.Error.Lens
-- Here is a fairly typical situation, where we have low level errors in certain
@jozefg
jozefg / queue.idr
Last active August 29, 2015 14:14
Queue in Idris
module queue
import Data.Vect
-- Here's the port of the Liquid Haskell blog post on amortized
-- queues. The tricksy bit is that the "amortized" bit depends on
-- laziness. This means that while in the REPL (where Idris is lazy)
-- this is reasonably efficient. It compiles absolutely horribly
-- though because each time push or pop something we rotate the whole
-- damned thing.