{-# OPTIONS_GHC -Wunused-imports #-}

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
(Help -> Help -> Bool) -> (Help -> Help -> Bool) -> Eq Help
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Help -> Help -> Bool
== :: Help -> Help -> Bool
$c/= :: Help -> Help -> Bool
/= :: Help -> Help -> Bool
Eq, Int -> Help -> ShowS
[Help] -> ShowS
Help -> String
(Int -> Help -> ShowS)
-> (Help -> String) -> ([Help] -> ShowS) -> Show Help
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Help -> ShowS
showsPrec :: Int -> Help -> ShowS
$cshow :: Help -> String
show :: Help -> String
$cshowList :: [Help] -> ShowS
showList :: [Help] -> ShowS
Show, (forall x. Help -> Rep Help x)
-> (forall x. Rep Help x -> Help) -> Generic Help
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
$cfrom :: forall x. Help -> Rep Help x
from :: forall x. Help -> Rep Help x
$cto :: forall x. Rep Help x -> Help
to :: forall x. Rep Help x -> Help
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
(HelpTopic -> HelpTopic -> Bool)
-> (HelpTopic -> HelpTopic -> Bool) -> Eq HelpTopic
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: HelpTopic -> HelpTopic -> Bool
== :: HelpTopic -> HelpTopic -> Bool
$c/= :: HelpTopic -> HelpTopic -> Bool
/= :: HelpTopic -> HelpTopic -> Bool
Eq, Int -> HelpTopic -> ShowS
[HelpTopic] -> ShowS
HelpTopic -> String
(Int -> HelpTopic -> ShowS)
-> (HelpTopic -> String)
-> ([HelpTopic] -> ShowS)
-> Show HelpTopic
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> HelpTopic -> ShowS
showsPrec :: Int -> HelpTopic -> ShowS
$cshow :: HelpTopic -> String
show :: HelpTopic -> String
$cshowList :: [HelpTopic] -> ShowS
showList :: [HelpTopic] -> ShowS
Show, (forall x. HelpTopic -> Rep HelpTopic x)
-> (forall x. Rep HelpTopic x -> HelpTopic) -> Generic HelpTopic
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
$cfrom :: forall x. HelpTopic -> Rep HelpTopic x
from :: forall x. HelpTopic -> Rep HelpTopic x
$cto :: forall x. Rep HelpTopic x -> HelpTopic
to :: forall x. Rep HelpTopic x -> HelpTopic
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 = String -> [(String, HelpTopic)] -> Maybe HelpTopic
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)
--