module UVMHS.Lib.Options 
  ( module UVMHS.Lib.Options
  , module System.Console.GetOpt
  ) where

import UVMHS.Core

import System.Console.GetOpt (OptDescr,ArgDescr)

import System.Console.GetOpt as Opt

option  𝐿   𝐿 𝕊  ArgDescr a  𝕊  OptDescr a
option :: forall a. 𝐿 ℂ -> 𝐿 𝕊 -> ArgDescr a -> 𝕊 -> OptDescr a
option 𝐿 ℂ
cs 𝐿 𝕊
ss ArgDescr a
ad 𝕊
s = [ℂ] -> [[ℂ]] -> ArgDescr a -> [ℂ] -> OptDescr a
forall a. [ℂ] -> [[ℂ]] -> ArgDescr a -> [ℂ] -> OptDescr a
Opt.Option (𝐿 ℂ -> [ℂ]
forall a b. CHS a b => a -> b
tohs 𝐿 ℂ
cs) (𝐿 [ℂ] -> [[ℂ]]
forall a b. CHS a b => a -> b
tohs (𝐿 [ℂ] -> [[ℂ]]) -> 𝐿 [ℂ] -> [[ℂ]]
forall a b. (a -> b) -> a -> b
$ (𝕊 -> [ℂ]) -> 𝐿 𝕊 -> 𝐿 [ℂ]
forall a b. (a -> b) -> 𝐿 a -> 𝐿 b
forall (t :: * -> *) a b. Functor t => (a -> b) -> t a -> t b
map 𝕊 -> [ℂ]
tohsChars 𝐿 𝕊
ss) ArgDescr a
ad ([ℂ] -> OptDescr a) -> [ℂ] -> OptDescr a
forall a b. (a -> b) -> a -> b
$ 𝕊 -> [ℂ]
tohsChars 𝕊
s

noArg  a  ArgDescr a
noArg :: forall a. a -> ArgDescr a
noArg = a -> ArgDescr a
forall a. a -> ArgDescr a
Opt.NoArg

reqArg  (𝕊  a)  𝕊  ArgDescr a
reqArg :: forall a. (𝕊 -> a) -> 𝕊 -> ArgDescr a
reqArg 𝕊 -> a
f 𝕊
s = ([ℂ] -> a) -> [ℂ] -> ArgDescr a
forall a. ([ℂ] -> a) -> [ℂ] -> ArgDescr a
Opt.ReqArg (𝕊 -> a
f (𝕊 -> a) -> ([ℂ] -> 𝕊) -> [ℂ] -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
 [ℂ] -> 𝕊
forall t. ToIter ℂ t => t -> 𝕊
string) ([ℂ] -> ArgDescr a) -> [ℂ] -> ArgDescr a
forall a b. (a -> b) -> a -> b
$ 𝕊 -> [ℂ]
tohsChars 𝕊
s

optArg  (𝑂 𝕊  a)  𝕊  ArgDescr a
optArg :: forall a. (𝑂 𝕊 -> a) -> 𝕊 -> ArgDescr a
optArg 𝑂 𝕊 -> a
f 𝕊
s = (Maybe [ℂ] -> a) -> [ℂ] -> ArgDescr a
forall a. (Maybe [ℂ] -> a) -> [ℂ] -> ArgDescr a
Opt.OptArg (𝑂 𝕊 -> a
f (𝑂 𝕊 -> a) -> (𝑂 (𝐿 ℂ) -> 𝑂 𝕊) -> 𝑂 (𝐿 ℂ) -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
 (𝐿 ℂ -> 𝕊) -> 𝑂 (𝐿 ℂ) -> 𝑂 𝕊
forall a b. (a -> b) -> 𝑂 a -> 𝑂 b
forall (t :: * -> *) a b. Functor t => (a -> b) -> t a -> t b
map 𝐿 ℂ -> 𝕊
forall t. ToIter ℂ t => t -> 𝕊
string (𝑂 (𝐿 ℂ) -> a) -> (Maybe [ℂ] -> 𝑂 (𝐿 ℂ)) -> Maybe [ℂ] -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
 Maybe [ℂ] -> 𝑂 (𝐿 ℂ)
forall a b. CHS a b => b -> a
frhs) ([ℂ] -> ArgDescr a) -> [ℂ] -> ArgDescr a
forall a b. (a -> b) -> a -> b
$ 𝕊 -> [ℂ]
tohsChars 𝕊
s

optUsageInfo  𝕊  𝐿 (OptDescr a)  𝕊
optUsageInfo :: forall a. 𝕊 -> 𝐿 (OptDescr a) -> 𝕊
optUsageInfo 𝕊
s 𝐿 (OptDescr a)
ds = [ℂ] -> 𝕊
forall t. ToIter ℂ t => t -> 𝕊
string ([ℂ] -> 𝕊) -> [ℂ] -> 𝕊
forall a b. (a -> b) -> a -> b
$ [ℂ] -> [OptDescr a] -> [ℂ]
forall a. [ℂ] -> [OptDescr a] -> [ℂ]
Opt.usageInfo (𝕊 -> [ℂ]
tohsChars 𝕊
s) ([OptDescr a] -> [ℂ]) -> [OptDescr a] -> [ℂ]
forall a b. (a -> b) -> a -> b
$ 𝐿 (OptDescr a) -> [OptDescr a]
forall a b. CHS a b => a -> b
tohs 𝐿 (OptDescr a)
ds

parseOptions  𝐿 (OptDescr a)  𝐿 𝕊  (𝐿 a  𝐿 𝕊  𝐿 𝕊)
parseOptions :: forall a. 𝐿 (OptDescr a) -> 𝐿 𝕊 -> (𝐿 a ∧ 𝐿 𝕊) ∧ 𝐿 𝕊
parseOptions 𝐿 (OptDescr a)
opts 𝐿 𝕊
args = 
  ((𝐿 a ∧ 𝐿 (𝐿 ℂ)) -> 𝐿 a ∧ 𝐿 𝕊)
-> (𝐿 (𝐿 ℂ) -> 𝐿 𝕊)
-> ((𝐿 a ∧ 𝐿 (𝐿 ℂ)) ∧ 𝐿 (𝐿 ℂ))
-> (𝐿 a ∧ 𝐿 𝕊) ∧ 𝐿 𝕊
forall a₁ a₂ b₁ b₂.
(a₁ -> a₂) -> (b₁ -> b₂) -> (a₁ ∧ b₁) -> a₂ ∧ b₂
mapPair ((𝐿 (𝐿 ℂ) -> 𝐿 𝕊) -> (𝐿 a ∧ 𝐿 (𝐿 ℂ)) -> 𝐿 a ∧ 𝐿 𝕊
forall b₁ b₂ a. (b₁ -> b₂) -> (a ∧ b₁) -> a ∧ b₂
mapSnd ((𝐿 (𝐿 ℂ) -> 𝐿 𝕊) -> (𝐿 a ∧ 𝐿 (𝐿 ℂ)) -> 𝐿 a ∧ 𝐿 𝕊)
-> (𝐿 (𝐿 ℂ) -> 𝐿 𝕊) -> (𝐿 a ∧ 𝐿 (𝐿 ℂ)) -> 𝐿 a ∧ 𝐿 𝕊
forall a b. (a -> b) -> a -> b
$ (𝐿 ℂ -> 𝕊) -> 𝐿 (𝐿 ℂ) -> 𝐿 𝕊
forall a b. (a -> b) -> 𝐿 a -> 𝐿 b
forall (t :: * -> *) a b. Functor t => (a -> b) -> t a -> t b
map 𝐿 ℂ -> 𝕊
forall t. ToIter ℂ t => t -> 𝕊
string) ((𝐿 ℂ -> 𝕊) -> 𝐿 (𝐿 ℂ) -> 𝐿 𝕊
forall a b. (a -> b) -> 𝐿 a -> 𝐿 b
forall (t :: * -> *) a b. Functor t => (a -> b) -> t a -> t b
map 𝐿 ℂ -> 𝕊
forall t. ToIter ℂ t => t -> 𝕊
string) (((𝐿 a ∧ 𝐿 (𝐿 ℂ)) ∧ 𝐿 (𝐿 ℂ)) -> (𝐿 a ∧ 𝐿 𝕊) ∧ 𝐿 𝕊)
-> ((𝐿 a ∧ 𝐿 (𝐿 ℂ)) ∧ 𝐿 (𝐿 ℂ)) -> (𝐿 a ∧ 𝐿 𝕊) ∧ 𝐿 𝕊
forall a b. (a -> b) -> a -> b
$
    ([a], [[ℂ]], [[ℂ]]) -> (𝐿 a ∧ 𝐿 (𝐿 ℂ)) ∧ 𝐿 (𝐿 ℂ)
forall a b. CHS a b => b -> a
frhs (([a], [[ℂ]], [[ℂ]]) -> (𝐿 a ∧ 𝐿 (𝐿 ℂ)) ∧ 𝐿 (𝐿 ℂ))
-> ([a], [[ℂ]], [[ℂ]]) -> (𝐿 a ∧ 𝐿 (𝐿 ℂ)) ∧ 𝐿 (𝐿 ℂ)
forall a b. (a -> b) -> a -> b
$ ArgOrder a -> [OptDescr a] -> [[ℂ]] -> ([a], [[ℂ]], [[ℂ]])
forall a.
ArgOrder a -> [OptDescr a] -> [[ℂ]] -> ([a], [[ℂ]], [[ℂ]])
Opt.getOpt ArgOrder a
forall a. ArgOrder a
Opt.RequireOrder (𝐿 (OptDescr a) -> [OptDescr a]
forall a b. CHS a b => a -> b
tohs 𝐿 (OptDescr a)
opts) ([[ℂ]] -> ([a], [[ℂ]], [[ℂ]])) -> [[ℂ]] -> ([a], [[ℂ]], [[ℂ]])
forall a b. (a -> b) -> a -> b
$ 𝐿 [ℂ] -> [[ℂ]]
forall a b. CHS a b => a -> b
tohs (𝐿 [ℂ] -> [[ℂ]]) -> 𝐿 [ℂ] -> [[ℂ]]
forall a b. (a -> b) -> a -> b
$ (𝕊 -> [ℂ]) -> 𝐿 𝕊 -> 𝐿 [ℂ]
forall a b. (a -> b) -> 𝐿 a -> 𝐿 b
forall (t :: * -> *) a b. Functor t => (a -> b) -> t a -> t b
map 𝕊 -> [ℂ]
tohsChars 𝐿 𝕊
args