-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Simple command line argument parsing -- @package getopt-generics @version 0.8 -- | getopt-generics tries to make it very simple to create -- command line argument parsers. An introductory example can be found in -- the README. module System.Console.GetOpt.Generics -- | Parses command line arguments (gotten from withArgs) and -- returns the parsed value. This function should be enough for simple -- use-cases. -- -- May throw the following exceptions: -- --
-- to . from === id :: a -> a -- from . to === id :: Rep a -> Rep a ---- -- You typically don't define instances of this class by hand, but rather -- derive the class instance automatically. -- -- Option 1: Derive via the built-in GHC-generics. For this, you -- need to use the DeriveGeneric extension to first derive an -- instance of the Generic class from module GHC.Generics. -- With this, you can then give an empty instance for Generic, and -- the default definitions will just work. The pattern looks as follows: -- --
-- import qualified GHC.Generics as GHC -- import Generics.SOP -- -- ... -- -- data T = ... deriving (GHC.Generic, ...) -- -- instance Generic T -- empty -- instance HasDatatypeInfo T -- empty, if you want/need metadata ---- -- Option 2: Derive via Template Haskell. For this, you need to -- enable the TemplateHaskell extension. You can then use -- deriveGeneric from module Generics.SOP.TH to have the -- instance generated for you. The pattern looks as follows: -- --
-- import Generics.SOP -- import Generics.SOP.TH -- -- ... -- -- data T = ... -- -- deriveGeneric ''T -- derives HasDatatypeInfo as well ---- -- Tradeoffs: Whether to use Option 1 or 2 is mainly a matter of -- personal taste. The version based on Template Haskell probably has -- less run-time overhead. -- -- Non-standard instances: It is possible to give Generic -- instances manually that deviate from the standard scheme, as long as -- at least -- --
-- to . from === id :: a -> a ---- -- still holds. class (SingI [[*]] (Code a), All [*] (SingI [*]) (Code a)) => Generic a where type family Code a :: [[*]] -- | A class of datatypes that have associated metadata. -- -- It is possible to use the sum-of-products approach to generic -- programming without metadata. If you need metadata in a function, an -- additional constraint on this class is in order. -- -- You typically don't define instances of this class by hand, but rather -- derive the class instance automatically. See the documentation of -- Generic for the options. class HasDatatypeInfo a -- | Require a constraint for every element of a list of lists. -- -- If you have a datatype that is indexed over a type-level list of -- lists, then you can use All2 to indicate that all elements of -- the innert lists must satisfy a given constraint. -- -- Example: The constraint -- --
-- All2 Eq '[ '[ Int ], '[ Bool, Char ] ] ---- -- is equivalent to the constraint -- --
-- (Eq Int, Eq Bool, Eq Char) ---- -- Example: A type signature such as -- --
-- f :: All2 Eq xss => SOP I xs -> ... ---- -- means that f can assume that all elements of the sum of -- product satisfy Eq. -- | The code of a datatype. -- -- This is a list of lists of its components. The outer list contains one -- element per constructor. The inner list contains one element per -- constructor argument (field). -- -- Example: The datatype -- --
-- data Tree = Leaf Int | Node Tree Tree ---- -- is supposed to have the following code: -- --
-- type instance Code (Tree a) = -- '[ '[ Int ] -- , '[ Tree, Tree ] -- ] ---- | A concrete, poly-kinded proxy type data Proxy (t :: k) :: k -> * Proxy :: Proxy instance [overlap ok] Typeable FieldState instance [overlap ok] Eq OutputInfoFlag instance [overlap ok] Ord OutputInfoFlag instance [overlap ok] Option Double instance [overlap ok] Option Float instance [overlap ok] Option Integer instance [overlap ok] Option Int instance [overlap ok] Option String instance [overlap ok] Option Bool instance [overlap ok] Option a => Option (Maybe a) instance [overlap ok] Option a => Option [a]