Skip to content

m-bock/purescript-data-default

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Default values for PureScript types

Resources

Stars

Watchers

Forks

Packages

No packages published