I use this to run a slapd instance for testing schemata, searched, etc. during development.
mkdir -p schema
{-# LANGUAGE GeneralizedNewtypeDeriving #-} | |
{-# LANGUAGE TemplateHaskell #-} | |
{-# LANGUAGE OverloadedStrings #-} | |
module Main where | |
import Control.Applicative | |
import Control.Monad.Except | |
import Control.Monad.IO.Class () | |
import Control.Monad.Reader |
module Main where | |
import Control.Applicative | |
import Data.Char | |
import Data.List | |
import Options.Applicative | |
import Options.Applicative.Types | |
-- * Options parsers |
module Main where | |
import Control.Applicative | |
import Data.Char | |
import Data.List | |
import Options.Applicative | |
import Options.Applicative.Types | |
-- * Options parsers |
#!/bin/sh | |
# | |
# Access a shared secret file. | |
set -eu | |
error() { | |
echo $1 | |
exit 1 | |
} |
module Main where | |
import System.Exit | |
import System.Process | |
main :: IO () | |
main = do | |
(c1, o1, e1) <- readProcessWithExitCode "ghc" ["-ilib", "-o", "/tmp/failure", "test/fail.hs"] "" | |
(c2, o2, e2) <- readProcessWithExitCode "ghc" ["-ilib", "-o", "/tmp/passure", "test/pass.hs"] "" |
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE KindSignatures #-} | |
{-# LANGUAGE MultiParamTypeClasses #-} | |
module Foo where | |
import GHC.TypeLits | |
data Header (sym :: Symbol) (val :: Symbol) | |
type Foo = '[Header "X-Forwarded-For" "Satan"] |
sealed abstract class Validation[T] { | |
def must(p: (T => Boolean), error: String): Validation[T] | |
} | |
object Validation { | |
def apply[T](value: T): Validation[T] = Valid(value) | |
} | |
case class Invalid[T](value: T, errors: List[String]) extends Validation[T] { | |
def must(p: (T => Boolean), error: String): Validation[T] = |
Copyright Thomas Sutton (c) 2015 | |
All rights reserved. | |
Redistribution and use in source and binary forms, with or without | |
modification, are permitted provided that the following conditions are met: | |
* Redistributions of source code must retain the above copyright | |
notice, this list of conditions and the following disclaimer. |
module Set where | |
import Data.Set (Set) | |
import qualified Data.Set as S | |
-- | Compare two 'Set's by inclusion or, failing that, by size. | |
compareInclusion :: (Ord e) => Set e -> Set e -> Ordering | |
compareInclusion s1 s2 = | |
let lt = S.isSubsetOf s1 s2 | |
gt = S.isSubsetOf s2 s1 |