- Bugfix of memoization edge-cases
- Fixed issue of callable features not being inheritable
data
,trait
, andcomplect
now consistently return callable constructors instead of objects/constructors (#64)Complected
is no longer exported and has been eliminated- Updated README
- Trait is not longer callable and must be complected before use.
- Due to the above, primitive traits and partial application are no longer supported.
data
andtrait
can now extend complected objects directly.Symbol(extend)
deprecated.trait
anddata
are now overloaded to use the first argument as the extension object.- Parameterized data decls are used to make complected objects parameterized.
- Pattern matching functionality is now used via a
Pattern
object. - updated README
- updated dependencies
- Fixed package.json module export configuration
- Defined *.d.ts
- Implemented derived fields
- Updated README
Data
andTrait
are now lowercase:data
andtrait
- Removed data-shorthand syntax
- Property declarations must now be object literals instead of arrays.
- Property Guards now available.
- Deprecated and removed symbols
data
,isSingleton
,variant
,variantName
- Added utility functions:
isDataVariant
,isDataDecl
,isTrait
,isComplectedVariant
- Updated README
- Updated dependencies
- Introduced
complect
to combine data and trait declarations - Updated package keywords to include
Family Polymorphism
- Traits can now be parameterized with a family reference to utilize the ultimately complected object:
const myTrait = trait(dataDecl, (family) => ({ ... }))
- Enabled array destructuring on variants
- Traits support array pattern matching
- Traits support Partial Application
- Trait declaration entries must have consistent arity
- Updated README
- Replaced
Symbol(all)
with_
inTrait
declarations - Added
Symbol(_)
for use withTrait
pattern matching - Added
Symbol(data)
for use withTrait
declarations - Added
Symbol(variantName)
to every data instance - Extended
Trait
to allow matching on primitivesNumber
,String
,Boolean
,BigInt
- Added pattern matching in Trait declarations
- Updated README
- Added SEO keywords
- Improved error messaging on invalid Trait declarations
- Added status badges to README
- Updated dependencies
Enabled a shorthand form for single variant Data declarations:
const Disk = Data({
Disk: ['position', 'velocity', 'radius', 'item']
})
Can now be written as:
const Disk = Data(['position', 'velocity', 'radius', 'item'])
The variantName
symbol has been removed. Each instance now has a variant
symbol reference that points to its constructor. If the variant is a singleton, it just points to itself.
Trait must now be provided its associated data declaration as the first argument:
const Color = Data({ Red: [], Green: [], Blue: [] });
const print = Trait(Color, {
Red() { return '#FF0000' },
Green() { return '#00FF00' },
Blue() { return '#0000FF' }
})
Inheritance is now accomplished on Data and Trait via use of this extend
property.
For Data
:
const IntExp = Data({ Lit: ['value'], Add: ['left', 'right'] })
const IntBoolExp = Data({
[extend]: IntExp,
Bool: ['value'],
Iff: ['pred', 'ifTrue', 'ifFalse']
})
For Trait
:
const intPrint = Trait(IntExp, {
Lit({ value }) { ... },
Add({ left, right }) { ... }
})
const intBoolPrint = Trait(IntBoolExp, {
[extend]: intPrint,
Bool({ value }) { ... },
Iff({ pred, ifTrue, ifFalse }) { ... }
});
The README now documents the above. Additionally an example of overriding [apply]
has been provided
Project dependencies updated to latest versions
- Updated
README.md
to reflect npm usage. - Updated package keywords
- Created npm package
- Renamed
typeName
symbol tovariantName
- Exposed
variantName
andisTrait
symbols - Data variants are reverted back to immutable.
- Non-singleton Data variants now utilize object pooling so that
Point3(1,2,3) === Point3({x:1,y:2,z:3})
- Removed
@final-hill/multi-key-map
dependency
- Added webpack build
- Added source mapping
- Added missing mutability test
- Updated dependencies
- Enabled mutability of data variant fields. Variants are still sealed.
Data
now supports lazy fields:
const Person = Data({
Employee: ['firstName', 'lastName', 'fullName']
})
const p = Person.Employee({
firstName: 'John',
lastName: 'Doe',
// becomes a getter
fullName: () => `${p.firstName} ${p.lastName}`
})
p.fullName === 'John Doe'
- Added
memoFix
for managing self recursive traits
- Bugfix of singleton Data variants to no longer extend
Object.prototype
- Bugfix of single parameter Data calls to differentiate object literals from object params
- Data variants can now be called with positional parameters
- Updated README
- Updated README.md
- Added
all
option toTrait
- Exposed
isData
andisSingleton
symbols - Removed dead code
- Updated license
- Fixed
dist
script - Updated README.md
- Exporting
apply
symbol - Bugfix of Trait overloading
- Fixed extensibility unit tests
- Created arithmetic unit tests
- Replaced Object Algebra approach with an alternative
- Re-enabled GitHub publish workflow
- Including
dist
folder in repo to support direct installation from repo - Disabled GitHub publish workflow
- package config updates
- Fixed family polymorphism references
- Replaced npm publish pipeline with GitHub publish
- npm publish pipeline fix
- Initial checkin