Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Cell references & indexing.
Synopsis
- newtype Column_Ref = Column_Ref {}
- type Column_Range = (Column_Ref, Column_Ref)
- type Row_Ref = Int
- row_index :: Row_Ref -> Int
- type Row_Range = (Row_Ref, Row_Ref)
- type Cell_Ref = (Column_Ref, Row_Ref)
- type Cell_Range = (Cell_Ref, Cell_Ref)
- letter_index :: Char -> Int
- index_letter :: Int -> Char
- column_index :: Column_Ref -> Int
- interior_column_index :: Column_Range -> Column_Ref -> Int
- column_ref :: Int -> Column_Ref
- column_ref_pred :: Column_Ref -> Column_Ref
- column_ref_succ :: Column_Ref -> Column_Ref
- column_indices :: Column_Range -> (Int, Int)
- column_range :: Column_Range -> [Column_Ref]
- column_in_range :: Column_Range -> Column_Ref -> Bool
- column_range_size :: Column_Range -> Int
- row_range :: Row_Range -> [Row_Ref]
- cell_ref_minima :: Cell_Ref
- parse_cell_ref :: String -> Maybe Cell_Ref
- is_cell_ref :: String -> Bool
- parse_cell_ref_err :: String -> Cell_Ref
- cell_ref_pp :: Cell_Ref -> String
- cell_index :: Cell_Ref -> (Int, Int)
- index_to_cell :: (Int, Int) -> Cell_Ref
- parse_cell_index :: String -> (Int, Int)
- cell_range :: Cell_Range -> [Cell_Ref]
- cell_range_row_order :: Cell_Range -> [Cell_Ref]
Documentation
newtype Column_Ref Source #
A
indexed case-insensitive column references. The column following Z
is AA
.
Instances
type Column_Range = (Column_Ref, Column_Ref) Source #
Inclusive range of column references.
type Cell_Ref = (Column_Ref, Row_Ref) Source #
Cell reference, column then row.
type Cell_Range = (Cell_Ref, Cell_Ref) Source #
Inclusive range of cell references.
letter_index :: Char -> Int Source #
Case folding letter to index function. Only valid for ASCII letters.
map letter_index ['A' .. 'Z'] == [0 .. 25] map letter_index ['a','d' .. 'm'] == [0,3 .. 12]
index_letter :: Int -> Char Source #
Inverse of letter_index
.
map index_letter [0,3 .. 12] == ['A','D' .. 'M']
column_index :: Column_Ref -> Int Source #
Translate column reference to 0
-index.
:set -XOverloadedStrings map column_index ["A","c","z","ac","XYZ"] == [0,2,25,28,17575]
interior_column_index :: Column_Range -> Column_Ref -> Int Source #
Column reference to interior index within specified range.
Type specialised index
.
map (Data.Ix.index ('A','Z')) ['A','C','Z'] == [0,2,25] map (interior_column_index ("A","Z")) ["A","C","Z"] == [0,2,25]
map (Data.Ix.index ('B','C')) ['B','C'] == [0,1] map (interior_column_index ("B","C")) ["B","C"] == [0,1]
column_ref :: Int -> Column_Ref Source #
Inverse of column_index
.
let c = ["A","Z","AA","AZ","BA","BZ","CA"] map column_ref [0,25,26,51,52,77,78] == c
column_ref (0+25+1+25+1+25+1) == "CA"
column_ref_pred :: Column_Ref -> Column_Ref Source #
Type specialised pred
.
column_ref_pred "DF" == "DE"
column_ref_succ :: Column_Ref -> Column_Ref Source #
Type specialised succ
.
column_ref_succ "DE" == "DF"
column_indices :: Column_Range -> (Int, Int) Source #
Bimap of column_index
.
column_indices ("b","p") == (1,15) column_indices ("B","IT") == (1,253)
column_range :: Column_Range -> [Column_Ref] Source #
Type specialised range
.
column_range ("L","R") == ["L","M","N","O","P","Q","R"] Data.Ix.range ('L','R') == "LMNOPQR"
column_in_range :: Column_Range -> Column_Ref -> Bool Source #
Type specialised inRange
.
map (column_in_range ("L","R")) ["A","N","Z"] == [False,True,False] map (column_in_range ("L","R")) ["L","N","R"] == [True,True,True]
map (Data.Ix.inRange ('L','R')) ['A','N','Z'] == [False,True,False] map (Data.Ix.inRange ('L','R')) ['L','N','R'] == [True,True,True]
column_range_size :: Column_Range -> Int Source #
Type specialised rangeSize
.
map column_range_size [("A","Z"),("AA","ZZ")] == [26,26 * 26] Data.Ix.rangeSize ('A','Z') == 26
cell_ref_minima :: Cell_Ref Source #
The standard uppermost leftmost cell reference, A1
.
Just cell_ref_minima == parse_cell_ref "A1"
parse_cell_ref :: String -> Maybe Cell_Ref Source #
Cell reference parser for standard notation of (column,row).
parse_cell_ref "CC348" == Just ("CC",348)
is_cell_ref :: String -> Bool Source #
isJust
of parse_cell_ref
.
cell_ref_pp :: Cell_Ref -> String Source #
Cell reference pretty printer.
cell_ref_pp ("CC",348) == "CC348"
cell_index :: Cell_Ref -> (Int, Int) Source #
Translate cell reference to 0
-indexed pair.
cell_index ("CC",348) == (80,347) Data.Ix.index ((Column_Ref "AA",1),(Column_Ref "ZZ",999)) (Column_Ref "CC",348) == 54293
index_to_cell :: (Int, Int) -> Cell_Ref Source #
Inverse of cell_index.
index_to_cell (80,347) == (Column_Ref "CC",348) index_to_cell (4,5) == (Column_Ref "E",6)
cell_range :: Cell_Range -> [Cell_Ref] Source #
Type specialised range
, cells are in column-order.
cell_range (("AA",1),("AC",1)) == [("AA",1),("AB",1),("AC",1)]
let r = [("AA",1),("AA",2),("AB",1),("AB",2),("AC",1),("AC",2)] cell_range (("AA",1),("AC",2)) == r
Data.Ix.range (('A',1),('C',1)) == [('A',1),('B',1),('C',1)]
let r = [('A',1),('A',2),('B',1),('B',2),('C',1),('C',2)] Data.Ix.range (('A',1),('C',2)) == r
cell_range_row_order :: Cell_Range -> [Cell_Ref] Source #
Variant of cell_range
in row-order.
let r = [("AA",1),("AB",1),("AC",1),("AA",2),("AB",2),("AC",2)] cell_range_row_order (("AA",1),("AC",2)) == r