3
Copyright (c) 2010, 2012 Lukas Mai
7
Redistribution and use in source and binary forms, with or without modification,
8
are permitted provided that the following conditions are met:
10
* Redistributions of source code must retain the above copyright notice, this
11
list of conditions and the following disclaimer.
12
* Redistributions in binary form must reproduce the above copyright notice,
13
this list of conditions and the following disclaimer in the documentation
14
and/or other materials provided with the distribution.
15
* Neither the name of the author nor the names of his contributors
16
may be used to endorse or promote products derived from this software
17
without specific prior written permission.
19
THIS SOFTWARE IS PROVIDED BY LUKAS MAI AND CONTRIBUTORS "AS IS" AND ANY
20
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
23
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1
32
module Data.Default (
2
33
-- | This module defines a class for types with a default value. Instances are
3
34
-- provided for '()', 'S.Set', 'M.Map', 'Int', 'Integer', 'Float', 'Double',
32
65
instance Default Float where def = 0
33
66
instance Default Double where def = 0
34
67
instance (Integral a) => Default (Ratio a) where def = 0
68
instance (Default a, RealFloat a) => Default (Complex a) where def = def :+ def
36
70
instance (Default r) => Default (e -> r) where def = const def
37
71
instance (Default a) => Default (IO a) where def = return def
56
90
instance (Default a, Default b, Default c) => Default (a, b, c) where def = (def, def, def)
57
91
instance (Default a, Default b, Default c, Default d) => Default (a, b, c, d) where def = (def, def, def, def)
58
92
instance (Default a, Default b, Default c, Default d, Default e) => Default (a, b, c, d, e) where def = (def, def, def, def, def)
94
instance Default TimeLocale where def = defaultTimeLocale