“Ken Thompson (Unix co-creater) has an automobile which he helped design. Unlike most automobiles, it has neither speedometer, nor gas gauge, nor any of the other numerous idiot lights which plague the modern driver. Rather, if the driver makes a mistake, a giant “?” lights up in the center of the dashboard. “The experienced driver,” says Thompson,“will usually know what’s wrong.”” - Unknown
This file contains 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
type Unprotected = | |
"login" | |
:> | |
Get '[HTML] LoginForm | |
:<|> | |
(ReqBody '[JSON] Login | |
:> PostNoContent '[JSON] (Headers '[Header "Set-Cookie" SetCookie] NoContent)) |
This file contains 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
data Nested = Empty | Nest Nested | |
deriving Show | |
grow :: Int -> Nested | |
grow 0 = Empty | |
grow n = Nest (grow $ n - 1) | |
depth :: Nested -> Int | |
depth Empty = 0 | |
depth (Nest xs) = 1 + depth xs |
This file contains 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 Marick where | |
maybe : b -> (a -> b) -> Maybe a -> b | |
maybe x f m = | |
case m of | |
Nothing -> x | |
Just y -> f y | |
type Model = Model |
This file contains 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.Exception (AsyncException (..), | |
SomeAsyncException (..)) | |
import GHC.Stack (currentCallStack) | |
import qualified Rerun | |
import qualified Spec | |
import Test.Hspec.Core.Spec | |
import Test.Hspec.Runner | |
import Test.Import |
This file contains 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
#include <stdlib.h> | |
extern unsigned int keylookup[]; | |
extern char * toASCIILut[]; | |
int comparator(const void * key, const void * member) { | |
unsigned int keyU = (*((unsigned int*) key)); | |
unsigned int memberU = (*((unsigned int *) member)); | |
if (keyU < memberU) { |
This file contains 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 TemplateHaskell #-} | |
import Data.Data | |
import qualified Data.Set as HS | |
import Data.Time | |
import Language.Haskell.TH.Syntax | |
foo :: (Data a) => a -> () | |
foo _ = () | |
This file contains 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
Alternatively (and equivalently), local implicit module bindings for Ord and Ord_int_rev make it possible | |
to override the behaviour at ints while using the automatic resolution behaviour to locate and use | |
the Ord_pair functor: | |
``` | |
let sort_both_ways ( items : ( int * int ) list ) = | |
let ord = | |
let implicit module Ord = Ord_int in | |
sort items | |
in |
This file contains 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
yoloSql :: Text -> [PersistValue] -> DB () | |
yoloSql stmt binds = do | |
(_ :: [Single Int]) <- rawSql stmt binds | |
return () |
This file contains 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 ScopedTypeVariables #-} | |
import Data.Monoid | |
import Data.List | |
import Debug.Trace | |
import Data.Maybe (fromMaybe) | |
dotrace x = trace (show x) x | |
getPrefs name = (`zip` [1..]) . lines <$> readFile name |