Skip to content

Instantly share code, notes, and snippets.

@JustusAdam
Created August 3, 2018 12:07
Show Gist options
  • Save JustusAdam/9025e58967c5cafefda0edba92274bab to your computer and use it in GitHub Desktop.
Save JustusAdam/9025e58967c5cafefda0edba92274bab to your computer and use it in GitHub Desktop.
I'm weird, so I made a haskell script to generate my ghci config.
#!stack runhaskell
import Data.Monoid
import Text.Printf
data ExtsHelper
= Prefixed String
[ExtsHelper]
| Values [String]
exts :: [ExtsHelper]
exts =
[ Prefixed "Overloaded" [Values ["Strings", "Lists"]]
, Prefixed
"Derive"
[ Values
[ "Functor"
, "Generic"
, "Traversable"
, "Foldable"
, "DataTypeable"
]
]
, Prefixed "Flexible" [Values ["Instances", "Contexts"]]
, Prefixed "Type" [Values ["SynonymInstances", "Operators", "Families"]]
, Values
[ "ExistentialQuantification"
, "FunctionalDependencies"
, "RankNTypes"
, "LambdaCase"
, "TupleSections"
, "MultiParamTypeClasses"
, "MultiWayIf"
, "NamedFieldPuns"
, "RecordWildCards"
, "PartialTypeSignatures"
, "QuasiQuotes"
, "TemplateHaskell"
, "ScopedTypeVariables"
, "StandaloneDeriving"
, "GADTs"
, "ViewPatterns"
]
]
flattenExts :: ExtsHelper -> [String]
flattenExts (Prefixed p vals) = vals >>= map (p <>) . flattenExts
flattenExts (Values v) = v
main :: IO ()
main =
writeFile ".ghci" $
printf
":set %v\n:set prompt \"λ>\"\n"
(unwords $ map ("-X" <>) $ concatMap flattenExts exts)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment