/purescript-data-default

Default values for PureScript types

Primary LanguageDhall

purescript-data-default

Latest release

Default values for purescript types. Inspired by Haskell's data-default package

Installation

spago install data-default

Documentation

Module documentation is published on Pursuit.

Example

import Data.Default
import Data.Maybe (Maybe)

-- Has value 0
x :: Int
x = def

-- Has value Nothing
y :: Maybe String
y = def

data User
  = User String Int

instance defaultUser :: Default User where
  def = User "Max" 99

-- Has value `User "Max" 99`
user :: User
user = def

-- Has value `{name : "", user : User "Max" 99 }`
record :: { name :: String, user :: User }
record = def