jxxcarlson / elm-spreadsheet / Cell

Cell specifies the kind content of Spreadsheet cells may have.

Types


type alias Cell =
Either Formula Value

Parse the text representation to see the internal representation of a cell:

> parse "3.1"
Right (Real 3.1)


type Formula
    = Formula Op Operands

Examples:

Parse the text representation to see the internal representation of a formula:

> parse "=A2+B3"
Left (Formula Add (Pair { left = { col = 1, row = 0 }, right = { col = 2, row = 1 } }))

> parse "=sum(A2:A8)"
Left (Formula Add (Range { left = { col = 1, row = 0 }, right = { col = 7, row = 0 } }))

> parse "=sum(B3:B9)"
Left (Formula Add (Range { left = { col = 2, row = 1 }, right = { col = 8, row = 1 } }))


type Value
    = Integer Basics.Int
    | Real Basics.Float
    | Boolean Basics.Bool
    | String String
    | Undefined


type alias Index =
{ row : Basics.Int, col : Basics.Int }


type Op
    = NoOp
    | Add
    | Sub
    | Mul
    | Div


type Operands
    = Pair RawOperands
    | Range RawOperands


type alias RawOperands =
{ left : Index
, right : Index 
}

Functions

render : Cell -> String

isValue : Cell -> Basics.Bool

mapReal : (Basics.Float -> Basics.Float) -> Cell -> Cell

opFromString : String -> Op

opFromString2 : String -> Op

realValue : Cell -> Maybe Basics.Float

stringFromOp : Op -> String