- Don't use partial functions (head, read, tail, fromJust, fail (in IO), error, undefined ... )
- Functions are your friend, use lots of them and keep them small.
- 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# language KindSignatures #-} | |
{-# language PolyKinds #-} | |
{-# language DataKinds #-} | |
{-# language TypeFamilies #-} | |
{-# language RankNTypes #-} | |
{-# language NoImplicitPrelude #-} | |
{-# language FlexibleContexts #-} | |
{-# language MultiParamTypeClasses #-} | |
{-# language GADTs #-} | |
{-# language ConstraintKinds #-} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE LambdaCase #-} | |
module Main where | |
import Control.Applicative (liftA2) | |
import Control.Monad.Reader | |
type Varname = String | |
type Env = [(Varname, Dom)] | |
data Dom |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- This file is a parsing experiment | |
-- Copyright (C) 2015 Fraser Tweedale | |
-- | |
-- This software is free software: you can redistribute it and/or modify | |
-- it under the terms of the GNU Affero General Public License as published by | |
-- the Free Software Foundation, either version 3 of the License, or | |
-- (at your option) any later version. | |
-- | |
-- This program is distributed in the hope that it will be useful, | |
-- but WITHOUT ANY WARRANTY; without even the implied warranty of |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://twitter.com/bitemyapp/status/672930049830596608 | |
a[data-nav=moments] { | |
display: none !important; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
import qualified System.Directory as Directory | |
import qualified System.FilePath as FilePath | |
import Control.Monad (forM, forM_, liftM) | |
import qualified Data.HashMap.Strict as HashMap | |
import Text.Printf (printf) | |
isFile :: FilePath -> IO Bool | |
isFile = Directory.doesFileExist |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE ForeignFunctionInterface, JavaScriptFFI #-} | |
import Reflex.Dom | |
import Data.Monoid | |
import GHCJS.Types | |
import GHCJS.Foreign | |
import GHCJS.DOM.Element | |
import GHCJS.DOM.Types | |
import Control.Monad.IO.Class | |
newtype LeafletMap = LeafletMap { unLeafletMap :: JSRef LeafletMap } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{- | |
DPLL from the textbook: | |
function DPLL(clauses, symbols, model ) returns true or false | |
if every clause in clauses is true in model then return true | |
if some clause in clauses is false in model then return false | |
P , value ← FIND-PURE-SYMBOL (symbols, clauses, model ) | |
if P is non-null then return DPLL(clauses, symbols – P , model ∪ {P =value}) | |
P, value ← FIND-UNIT-CLAUSE (clauses, model) | |
if P is non-null then return DPLL(clauses, symbols – P , model ∪ {P =value}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
import Control.Applicative ((<$>), (<*>)) | |
import Control.Monad.IO.Class (liftIO) | |
import Control.Monad.Trans.State (StateT) | |
import Data.Conduit (($$), (=$=), (=$) | |
, Conduit, Sink, Source | |
, await, yield) | |
import qualified Data.Conduit.List as CL | |
import qualified Data.Vector.Unboxed as V |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |