types

package
v1.9.12 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 6, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package types defines the CalcMark type system

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Boolean

type Boolean struct {
	Value bool
}

Boolean represents a boolean value

func NewBoolean

func NewBoolean(value any) (*Boolean, error)

NewBoolean creates a Boolean from various input types

func (*Boolean) Equal

func (b *Boolean) Equal(other Type) bool

Equal checks equality with another Type

func (*Boolean) String

func (b *Boolean) String() string

String returns "true" or "false"

func (*Boolean) ToBool

func (b *Boolean) ToBool() bool

ToBool converts to Go bool

func (*Boolean) TypeName

func (b *Boolean) TypeName() string

TypeName returns "Boolean"

type Currency

type Currency struct {
	Value        decimal.Decimal
	Symbol       string
	SourceFormat string // Original formatting from source (e.g., "$1,000", "$10000")
}

Currency represents a currency value with a symbol

func NewCurrency

func NewCurrency(value any, symbol string) (*Currency, error)

NewCurrency creates a Currency from various input types

func NewCurrencyWithFormat

func NewCurrencyWithFormat(value any, symbol string, sourceFormat string) (*Currency, error)

NewCurrencyWithFormat creates a Currency with source format preservation

func (*Currency) Equal

func (c *Currency) Equal(other Type) bool

Equal checks equality with another Type

func (*Currency) String

func (c *Currency) String() string

String returns the string representation with currency symbol If SourceFormat is set, returns that; otherwise formats as $X.XX

func (*Currency) ToDecimal

func (c *Currency) ToDecimal() decimal.Decimal

ToDecimal converts to decimal.Decimal

func (*Currency) TypeName

func (c *Currency) TypeName() string

TypeName returns "Currency"

type Number

type Number struct {
	Value        decimal.Decimal
	SourceFormat string // Original formatting from source (e.g., "1,000", "1k", "10000")
}

Number represents a numeric value with arbitrary precision

func NewNumber

func NewNumber(value any) (*Number, error)

NewNumber creates a Number from various input types

func NewNumberWithFormat

func NewNumberWithFormat(value any, sourceFormat string) (*Number, error)

NewNumberWithFormat creates a Number with source format preservation

func (*Number) Equal

func (n *Number) Equal(other Type) bool

Equal checks equality with another Type

func (*Number) String

func (n *Number) String() string

String returns the string representation of the number If SourceFormat is set, returns that; otherwise formats with default rules

func (*Number) ToDecimal

func (n *Number) ToDecimal() decimal.Decimal

ToDecimal converts to decimal.Decimal

func (*Number) TypeName

func (n *Number) TypeName() string

TypeName returns "Number"

type Type

type Type interface {
	String() string
	Equal(other Type) bool
	TypeName() string
}

Type is the interface that all CalcMark types implement

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL