Skip to content

Instantly share code, notes, and snippets.

@sjoerdvisscher
Last active December 15, 2015 04:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sjoerdvisscher/5204371 to your computer and use it in GitHub Desktop.
Save sjoerdvisscher/5204371 to your computer and use it in GitHub Desktop.
The Q42 e-mail signature as executable Haskell. Returns 42 times Q42 when executed.
{-# LANGUAGE ParallelListComp, MonadComprehensions, RebindableSyntax #-}
import Prelude
data Names = Q42 Names | BV | Names :// (Int -> Int) | Waldorpstraat Int Names | F | Den Names | Haag | KvK Int
instance Show Names where show _ = "Q42"
infixr 9 ://
tel :: Int -> Int -> Int -> Names
tel _ _ _ = F
http :: Names
http = Haag
q42, nl :: Int -> Int
q42 = (+42)
nl = (*5)
guard :: Names -> [()]
guard name = replicate (f name) ()
where
f (Q42 n) = 42 * f n
f BV = 5
f (_ :// g) = g 4
f (Waldorpstraat i _) = i - 10
f F = 100
f (Den n) = 2 * f n
f Haag = 3
f (KvK i) = i
mzip :: [a] -> [b] -> [(a, b)]
mzip = zip
signature :: [Names]
signature = [ Q42 BV | tel 070 44523 42 | http://q42.nl | Waldorpstraat 17F, Den Haag | KvK 30164662 ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment