Skip to content

Instantly share code, notes, and snippets.

@skiold
Forked from bgamari/NestedOptParseApplicative.hs
Created February 11, 2016 14:44
Show Gist options
  • Save skiold/4d35fe8bd5de775670ff to your computer and use it in GitHub Desktop.
Save skiold/4d35fe8bd5de775670ff to your computer and use it in GitHub Desktop.
import Options.Applicative
import Control.Monad
parser :: Parser (IO ())
parser = subparser $
command "add" (info (helper <*> addMode) mempty)
<> command "test" (info (pure $ putStrLn "testing") mempty)
where
addMode :: Parser (IO ())
addMode = subparser $
command "add" (info (pure $ putStrLn "adding message") mempty)
<> command "remove" (info (pure $ putStrLn "removing message") mempty)
main :: IO ()
main = join $ execParser $ info (helper <*> parser) mempty
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment