Simple model of a politician in Haskell

August 19, 2013 in

Here is a simple model of a politician in Haskell, which you can use to create arbitrary politician instances. You only need to provide that particular politician's body of knowledge and its individual mapping between a statement and a corresponding fallacy. The answering is already implemented.

module Politics where
import Data.List
type Q = String
type S = String
data Statement = Statement Q S
data Fallacy =
AppealToProbability Statement
| ArgumentFromFallacy Statement
| AppealToAuthority Statement
| ArgumentFromSilence Statement
| AdHominem Statement
| AppealToFear Statement
class Politician a where
knowledge :: a -> [Statement]
lieify :: a -> Maybe Statement -> Maybe Fallacy
ask :: a -> Q -> Maybe Fallacy
ask a q = lieify a answer
knows = knowledge a
answer = find search knows
search (Statement qstn _) = qstn == q
view raw politician.hs hosted with ❤ by GitHub

Please note that the list of fallacies is very incomplete and needs expansion. Pull request, anyone? ;)

What I'd have wished Windows 8 to beFunSpIns - a recap of Rob Ashton's lessons - Das Intro