| Portability | Not portable |
|---|---|
| Stability | experimental |
| Maintainer | happs@googlegroups.com |
| Safe Haskell | None |
Happstack.Data.Default
Description
Provides default values for Haskell datatypes.
- class Data DefaultD a => Default a where
- defaultValue :: a
- defaultDefaultValue :: (Data DefaultD a, Default a) => a
- data DefaultD a = DefaultD {
- defaultValueD :: a
- defaultProxy :: Proxy DefaultD
The interface
class Data DefaultD a => Default a whereSource
The Default class provides a defaultValue value, which
is the default value for that type.
There is no instance for arbitrary types by default, but if you
declare an instance without providing the value then one will be
built using the first constructor. defaultValue is used to provide
values for any arguments of the constructor.
If you want an instance for all types then import Happstack.Data.Default.Generic.
Methods
defaultValue :: aSource
Instances
| Default Bool | |
| Default Char | |
| Default Double | |
| Default Float | |
| Default Int | |
| Default Int8 | |
| Default Int16 | |
| Default Int32 | |
| Default Int64 | |
| Default Integer | |
| Default Word | |
| Default Word8 | |
| Default Word16 | |
| Default Word32 | |
| Default Word64 | |
| Default () | |
| Data DefaultD a => Default a | |
| Default Element | |
| Default User | |
| Default Pass | |
| Default UserInfo | |
| Default ByteString | |
| Default Text | |
| Default Text | |
| Data DefaultD a => Default [a] | |
| Default t0 => Default (Proxy t0) | |
| Default a => Default (Maybe a) | |
| Default a => Default (ForeignPtr a) | |
| (Data DefaultD a, Ord a) => Default (Set a) | |
| (Default a, Default b) => Default (Either a b) | |
| (Default a, Default b) => Default (a, b) | |
| (Data DefaultD a, Data DefaultD b, Ord a) => Default (Map a b) | |
| (Default a, Default b, Default c) => Default (a, b, c) | |
| (Default a, Default b, Default c, Default d) => Default (a, b, c, d) |
Writing your own instances
defaultDefaultValue :: (Data DefaultD a, Default a) => aSource
This is the defaultValue that is used in an instance if you don't
specify one. It may be a useful building block when writing your own
instances.
Advanced usage
When writing your own generic functions for Default you may
need to access the class method through this datatype rather than
directly.
Constructors
| DefaultD | |
Fields
| |
defaultProxy :: Proxy DefaultDSource
When writing your own generic functions for Default you may
need this, the proxy value.