Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions data-default-class/Data/Default/Class.hs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,17 @@ class Default a where
def = to gdef
#endif

-- | A class to specify that complex type with a default wrapped type,
class Default1 (f :: * -> *) where
liftDef :: a -> f a

-- | Create a default value by making use of the 'Default1' instance
-- and the 'def' function as default for the item(s) wrapped in the object.
def1 :: (Default1 f, Default a)
=> f a -- ^ The default object constructed with the 'Default1' and the 'def'
-- of the wrapped item.
def1 = liftDef def

instance Default Int where def = 0
instance Default Int8 where def = 0
instance Default Int16 where def = 0
Expand Down