-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/

-- | Optional function arguments
--   
--   This library provides a type for specifying Optional function
--   arguments
--   
--   Read the tutorial in Data.Optional to learn more
@package optional-args
@version 1.0.2

-- | Use the Optional type for optional function arguments. For
--   example:
--   
--   
--   import Data.Optional
--   
--   greet :: Optional String -> String
--   greet (Specific name) = "Hello, " ++ name
--   greet  Default        = "Hello"
--   
--   
--   
--   >>> greet (Specific "John")
--   "Hello, John"
--   
--   >>> greet Default
--   "Hello"
--   
--   
--   The Optional type overloads as many Haskell literals as
--   possible so that you do not need to wrap values in Specific.
--   For example, if you enable the OverloadedStrings extension
--   you can use a naked string literal instead:
--   
--   
--   >>> :set -XOverloadedStrings
--   
--   >>> greet "John"
--   "Hello, John"
--   
--   
--   The Optional type also implements Num and
--   Fractional, so you can use numeric literals in place of
--   Optional values:
--   
--   
--   birthday :: Optional Int -> String
--   birthday (Specific age) = "You are " ++ show age ++ " years old!"
--   birthday  Default       = "You are one year older!"
--   
--   
--   
--   >>> birthday 20
--   "You are 20 years old!"
--   
--   >>> birthday Default
--   "You are one year older!"
--   
--   
--   The IsString, Num, and Fractional instances are
--   recursive, so you can wrap your types in a more descriptive newtype
--   and derive IsString, Num or Fractional:
--   
--   
--   {-# LANGUAGE GeneralizedNewtypeDeriving #-}
--   
--   import Data.Optional
--   import Data.String (IsString)
--   
--   newtype Name = Name { getName :: String } deriving (IsString)
--   
--   greet :: Optional Name -> String
--   greet (Specific name) = "Hello, " ++ getName name
--   greet  Default        = "Hello"
--   
--   newtype Age = Age { getAge :: Int } deriving (Num)
--   
--   birthday :: Optional Age -> String
--   birthday (Specific age) = "You are " ++ show (getAge age) ++ " years old!"
--   birthday  Default       = "You are one year older!"
--   
--   
--   ... and you would still be able to provide naked numeric or string
--   literals:
--   
--   
--   >>> :set -XOverloadedStrings
--   
--   >>> greet "John"
--   "Hello, John"
--   
--   >>> birthday 20
--   "You are 20 years old!"
--   
--   
--   You can use empty as a short-hand for a Default
--   argument:
--   
--   
--   >>> greet empty
--   "Hello"
--   
--   >>> birthday empty
--   "You are one year older!"
--   
--   
--   You can also use pure as a short-hand for a Specific
--   argument:
--   
--   
--   >>> greet (pure "John")
--   "Hello, John"
--   
--   >>> birthday (pure 20)
--   "You are 20 years old!"
--   
module Data.Optional

-- | A function argument that has a Default value
data Optional a
Default :: Optional a
Specific :: a -> Optional a

-- | The defaultTo function takes a default value and an
--   Optional value. If the Optional is Default, it
--   returns the default value; otherwise, it returns the value contained
--   in the Optional.
defaultTo :: a -> Optional a -> a

-- | Convert an Optional value into an instance of
--   Alternative.
fromOptional :: Alternative f => Optional a -> f a

-- | The optional function takes a default value, a function, and an
--   Optional value. If the Optional value is Default,
--   the function returns the default value. Otherwise, it applies the
--   function to the value inside the Optional and returns the
--   result.
optional :: b -> (a -> b) -> Optional a -> b

-- | The identity of <|>
--   
--   
--   empty <|> a     == a
--   a     <|> empty == a
--   
empty :: Alternative f => f a

-- | Lift a value into the Structure.
--   
--   
Examples
--   
--   
--   >>> pure 1 :: Maybe Int
--   Just 1
--   
--   
--   
--   >>> pure 'z' :: [Char]
--   "z"
--   
--   
--   
--   >>> pure (pure ":D") :: Maybe [String]
--   Just [":D"]
--   
pure :: Applicative f => a -> f a
instance GHC.Internal.Base.Alternative Data.Optional.Optional
instance GHC.Internal.Base.Applicative Data.Optional.Optional
instance GHC.Classes.Eq a => GHC.Classes.Eq (Data.Optional.Optional a)
instance GHC.Internal.Data.Foldable.Foldable Data.Optional.Optional
instance GHC.Internal.Real.Fractional a => GHC.Internal.Real.Fractional (Data.Optional.Optional a)
instance GHC.Internal.Base.Functor Data.Optional.Optional
instance GHC.Internal.Data.String.IsString a => GHC.Internal.Data.String.IsString (Data.Optional.Optional a)
instance GHC.Internal.Base.Monad Data.Optional.Optional
instance GHC.Internal.Base.MonadPlus Data.Optional.Optional
instance GHC.Internal.Base.Monoid a => GHC.Internal.Base.Monoid (Data.Optional.Optional a)
instance GHC.Internal.Num.Num a => GHC.Internal.Num.Num (Data.Optional.Optional a)
instance GHC.Internal.Base.Semigroup a => GHC.Internal.Base.Semigroup (Data.Optional.Optional a)
instance GHC.Internal.Show.Show a => GHC.Internal.Show.Show (Data.Optional.Optional a)
instance GHC.Internal.Data.Traversable.Traversable Data.Optional.Optional
