Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Utilities for arguments record with defaults
Useful for when you want to define a default value of an arguments record consisting of a mix of arguments with/without defaults.
The following code example explains it best:
data Args f = Args { hasNoDefault :: HKD f Int , hasDefault :: Bool } defaultArgs :: Incomplete Args defaultArgs = Args { hasNoDefault = noDefault , hasDefault = False } theArgs :: Complete Args theArgs = defaultArgs { hasNoDefault = 0 } useArgs :: Complete Args -> (Int, Bool) useArgs (Args a b) = (a, b)
Leaving out the hasNoDefault
field from theArgs
will result in a type
error.