Skip to content

Instantly share code, notes, and snippets.

@ajnsit
Created September 5, 2015 07:56
Show Gist options
  • Save ajnsit/e0ebc8d327c7ae1be132 to your computer and use it in GitHub Desktop.
Save ajnsit/e0ebc8d327c7ae1be132 to your computer and use it in GitHub Desktop.
Insult generator in Haskell
{-# LANGUAGE DeriveDataTypeable, QuasiQuotes #-}
module Main where
import Data.Char (toUpper)
import Data.List (intersperse)
import Data.String.Interpolate (i)
import System.Environment (getArgs)
main :: IO ()
main = getArgs >>= putStrLn . makeInsult
-- Actual generator
makeInsult :: [String] -> String
makeInsult [] = makeInsult ["dumbass"]
makeInsult (word:_) =
let insult = map toUpper word
remaining = filter (not . (`elem` insult)) ['A'..'Z']
spaced = intersperse ' '
in [i|#{spaced remaining}
You must be wondering what happened to the rest of the letters
.
.
They are written below
.
.
.
.
.
.
.
.
.
.
#{spaced insult}
|]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment