module Agda.Interaction.Options.Help
       (
         Help (..)
       , helpTopicUsage
       , string2HelpTopic
       , allHelpTopics
       ) where

import Control.DeepSeq

import GHC.Generics (Generic)

import Agda.Interaction.Options.Warnings

-- | Interface to the @help@ function
data Help
  = GeneralHelp
  -- ^ General usage information
  | HelpFor HelpTopic
  -- ^ Specialised usage information about TOPIC
  deriving (Help -> Help -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Help -> Help -> Bool
$c/= :: Help -> Help -> Bool
== :: Help -> Help -> Bool
$c== :: Help -> Help -> Bool
Eq, Int -> Help -> ShowS
[Help] -> ShowS
Help -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Help] -> ShowS
$cshowList :: [Help] -> ShowS
show :: Help -> String
$cshow :: Help -> String
showsPrec :: Int -> Help -> ShowS
$cshowsPrec :: Int -> Help -> ShowS
Show, forall x. Rep Help x -> Help
forall x. Help -> Rep Help x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Help x -> Help
$cfrom :: forall x. Help -> Rep Help x
Generic)

instance NFData Help

-- | List of Help Topics
-- NOTA BENE:
-- You need to add each new topic together with its name to @allHelpTopics@

data HelpTopic
  = Warning
  deriving (HelpTopic -> HelpTopic -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HelpTopic -> HelpTopic -> Bool
$c/= :: HelpTopic -> HelpTopic -> Bool
== :: HelpTopic -> HelpTopic -> Bool
$c== :: HelpTopic -> HelpTopic -> Bool
Eq, Int -> HelpTopic -> ShowS
[HelpTopic] -> ShowS
HelpTopic -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HelpTopic] -> ShowS
$cshowList :: [HelpTopic] -> ShowS
show :: HelpTopic -> String
$cshow :: HelpTopic -> String
showsPrec :: Int -> HelpTopic -> ShowS
$cshowsPrec :: Int -> HelpTopic -> ShowS
Show, forall x. Rep HelpTopic x -> HelpTopic
forall x. HelpTopic -> Rep HelpTopic x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep HelpTopic x -> HelpTopic
$cfrom :: forall x. HelpTopic -> Rep HelpTopic x
Generic)

instance NFData HelpTopic

allHelpTopics :: [(String, HelpTopic)]
allHelpTopics :: [(String, HelpTopic)]
allHelpTopics = [(String
"warning", HelpTopic
Warning)]

-- | Usage information generation

helpTopicUsage :: HelpTopic -> String
helpTopicUsage :: HelpTopic -> String
helpTopicUsage HelpTopic
tp = case HelpTopic
tp of
  HelpTopic
Warning -> String
usageWarning

-- | Conversion functions to strings

string2HelpTopic :: String -> Maybe HelpTopic
string2HelpTopic :: String -> Maybe HelpTopic
string2HelpTopic String
str = forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup String
str [(String, HelpTopic)]
allHelpTopics

-- UNUSED Liang-Ting Chen 2019-07-15
--helpTopic2String :: HelpTopic -> String
--helpTopic2String w = fromMaybe __IMPOSSIBLE__ $ lookup w (map swap allHelpTopics)
--