[Haskell-cafe] do we have something like isDefined or isNull in Haskell?

Bryan Burgers bryan.burgers at gmail.com
Thu Jun 15 08:05:58 EDT 2006


On 6/15/06, Vladimir Portnykh <vportnykh at hotmail.com> wrote:
> Suppose there is a data definition in Haskell:
> data MyType = MyType { date     :: Double,
>                    weight       :: Double,
>                   height        :: Double
>                 } deriving (Eq, Ord, Show)
>
> Is it possible to check if the field height, for example, is filled
> in(defined)? Can we give default values in Haskell?
>
> Many thanks and sorry fro so sily questions. Vladimir

You could make date, weight, and height "Maybe Double"s, then
isDefined = isJust and isNull = isNothing.

Bryan


More information about the Haskell-Cafe mailing list