Skip to content

Instantly share code, notes, and snippets.

View mwotton's full-sized avatar

Mark Wotton mwotton

View GitHub Profile
type Unprotected =
"login"
:>
Get '[HTML] LoginForm
:<|>
(ReqBody '[JSON] Login
:> PostNoContent '[JSON] (Headers '[Header "Set-Cookie" SetCookie] NoContent))
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
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

“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

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
#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) {
{-# LANGUAGE TemplateHaskell #-}
import Data.Data
import qualified Data.Set as HS
import Data.Time
import Language.Haskell.TH.Syntax
foo :: (Data a) => a -> ()
foo _ = ()
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
yoloSql :: Text -> [PersistValue] -> DB ()
yoloSql stmt binds = do
(_ :: [Single Int]) <- rawSql stmt binds
return ()
{-# 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