Skip to content

Commit ceda7ba

Browse files
committed
wip
1 parent 143d1eb commit ceda7ba

File tree

15 files changed

+132
-142
lines changed

15 files changed

+132
-142
lines changed

pub/xlsx/src/Codec/Xlsx/Formatted.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ data Format = Format
137137
}
138138
deriving (Eq, Show, Generic)
139139

140-
-- | Cell with formatting. '_cellStyle' property of 'formattedCell' is ignored
140+
-- | Cell with formatting. 'cellStyle' property of 'formattedCell' is ignored
141141
--
142142
-- See 'formatted' for more details.
143143
data FormattedCell = FormattedCell
@@ -264,9 +264,9 @@ toFormattedCells m merges StyleSheet {..} = applyMerges $ M.map toFormattedCell
264264
where
265265
toFormattedCell cell@Cell {..} =
266266
FormattedCell
267-
{ formattedCell = cell {_cellStyle = Nothing}, -- just to remove confusion
267+
{ formattedCell = cell {cellStyle = Nothing}, -- just to remove confusion
268268
formattedFormat =
269-
maybe def formatFromStyle $ flip M.lookup cellXfs =<< _cellStyle,
269+
maybe def formatFromStyle $ flip M.lookup cellXfs =<< cellStyle,
270270
formattedColSpan = 1,
271271
formattedRowSpan = 1
272272
}
@@ -368,7 +368,7 @@ formatCell (row, col) cell = do
368368
State FormattingState ((RowIndex, ColumnIndex), Cell)
369369
go (pos, c@FormattedCell {..}) = do
370370
styleId <- cellStyleId c
371-
return (pos, formattedCell {_cellStyle = styleId})
371+
return (pos, formattedCell {cellStyle = styleId})
372372

373373
-- | Cell block corresponding to a single 'FormattedCell'
374374
--

pub/xlsx/src/Codec/Xlsx/Lens.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ cellValueAt = cellValueAtRC
111111
-- | lens to read, write or delete cell value in a worksheet
112112
-- using row+column coordinates of that cell
113113
cellValueAtRC :: (RowIndex, ColumnIndex) -> Lens' Worksheet (Maybe CellValue)
114-
cellValueAtRC i = atCell i . non def . cellValue
114+
cellValueAtRC i = atCell i . non def . #cellValue
115115

116116
-- | lens to read, write or delete cell value in a worksheet
117117
-- using traditional x+y coordinates

pub/xlsx/src/Codec/Xlsx/Parser.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,11 +230,11 @@ extractSheetFast ar sst contentTypes caches wf = do
230230
fmap join . forM commentTarget $ getComments ar legacyDrPath
231231
let commentCells =
232232
M.fromList
233-
[ (fromSingleCellRefNoting r, def {_cellComment = Just cmnt})
233+
[ (fromSingleCellRefNoting r, def {cellComment = Just cmnt})
234234
| (r, cmnt) <- maybe [] CommentTable.toList commentsMap
235235
]
236236
assignComment withCmnt noCmnt =
237-
noCmnt & cellComment .~ (withCmnt ^. cellComment)
237+
noCmnt & #cellComment .~ (withCmnt ^. #cellComment)
238238
mergeComments = M.unionWith assignComment commentCells
239239
tables <- forM tableIds $ \rId -> do
240240
fp <- lookupRelPath filePath sheetRels rId
@@ -496,7 +496,7 @@ extractSheet ar sst contentTypes caches wf = do
496496

497497
commentCells =
498498
M.fromList
499-
[ (fromSingleCellRefNoting r, def {_cellComment = Just cmnt})
499+
[ (fromSingleCellRefNoting r, def {cellComment = Just cmnt})
500500
| (r, cmnt) <- maybe [] CommentTable.toList commentsMap
501501
]
502502
cells = cells0 `M.union` commentCells

pub/xlsx/src/Codec/Xlsx/Parser/Stream.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -604,10 +604,10 @@ addCellToRow txt = do
604604
IntMap.insert
605605
(unColumnIndex $ ps_cell_col_index st)
606606
( Cell
607-
{ _cellStyle = style,
608-
_cellValue = Just val,
609-
_cellComment = Nothing,
610-
_cellFormula = Nothing
607+
{ cellStyle = style,
608+
cellValue = Just val,
609+
cellComment = Nothing,
610+
cellFormula = Nothing
611611
}
612612
)
613613
$ ps_row st

pub/xlsx/src/Codec/Xlsx/Types/Cell.hs

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
{-# LANGUAGE DeriveGeneric #-}
33
{-# LANGUAGE OverloadedStrings #-}
44
{-# LANGUAGE RecordWildCards #-}
5-
{-# LANGUAGE TemplateHaskell #-}
65

76
module Codec.Xlsx.Types.Cell
87
( CellFormula (..),
@@ -14,10 +13,6 @@ module Codec.Xlsx.Types.Cell
1413
formulaDataFromCursor,
1514
applySharedFormulaOpts,
1615
Cell (..),
17-
cellStyle,
18-
cellValue,
19-
cellComment,
20-
cellFormula,
2116
CellMap,
2217
)
2318
where
@@ -49,14 +44,14 @@ import Text.XML.Cursor
4944
--
5045
-- See 18.3.1.40 "f (Formula)" (p. 1636)
5146
data CellFormula = CellFormula
52-
{ _cellfExpression :: FormulaExpression,
47+
{ cellfExpression :: FormulaExpression,
5348
-- | Specifies that this formula assigns a value to a name.
54-
_cellfAssignsToName :: Bool,
49+
cellfAssignsToName :: Bool,
5550
-- | Indicates that this formula needs to be recalculated
5651
-- the next time calculation is performed.
5752
-- [/Example/: This is always set on volatile functions,
5853
-- like =RAND(), and circular references. /end example/]
59-
_cellfCalculate :: Bool
54+
cellfCalculate :: Bool
6055
}
6156
deriving (Eq, Show, Generic)
6257

@@ -91,26 +86,26 @@ instance NFData SharedFormulaOptions
9186
simpleCellFormula :: Text -> CellFormula
9287
simpleCellFormula expr =
9388
CellFormula
94-
{ _cellfExpression = NormalFormula $ Formula expr,
95-
_cellfAssignsToName = False,
96-
_cellfCalculate = False
89+
{ cellfExpression = NormalFormula $ Formula expr,
90+
cellfAssignsToName = False,
91+
cellfCalculate = False
9792
}
9893

9994
sharedFormulaByIndex :: SharedFormulaIndex -> CellFormula
10095
sharedFormulaByIndex si =
10196
CellFormula
102-
{ _cellfExpression = SharedFormula si,
103-
_cellfAssignsToName = False,
104-
_cellfCalculate = False
97+
{ cellfExpression = SharedFormula si,
98+
cellfAssignsToName = False,
99+
cellfCalculate = False
105100
}
106101

107102
-- | Currently cell details include cell values, style ids and cell
108103
-- formulas (inline strings from @\<is\>@ subelements are ignored)
109104
data Cell = Cell
110-
{ _cellStyle :: Maybe Int,
111-
_cellValue :: Maybe CellValue,
112-
_cellComment :: Maybe Comment,
113-
_cellFormula :: Maybe CellFormula
105+
{ cellStyle :: Maybe Int,
106+
cellValue :: Maybe CellValue,
107+
cellComment :: Maybe Comment,
108+
cellFormula :: Maybe CellFormula
114109
}
115110
deriving (Eq, Show, Generic)
116111

@@ -119,8 +114,6 @@ instance NFData Cell
119114
instance Default Cell where
120115
def = Cell Nothing Nothing Nothing Nothing
121116

122-
makeLenses ''Cell
123-
124117
-- | Map containing cell values which are indexed by row and column
125118
-- if you need to use more traditional (x,y) indexing please you could
126119
-- use corresponding accessors from ''Codec.Xlsx.Lens''
@@ -133,10 +126,10 @@ type CellMap = Map (RowIndex, ColumnIndex) Cell
133126
formulaDataFromCursor ::
134127
Cursor -> [(CellFormula, Maybe (SharedFormulaIndex, SharedFormulaOptions))]
135128
formulaDataFromCursor cur = do
136-
_cellfAssignsToName <- fromAttributeDef "bx" False cur
137-
_cellfCalculate <- fromAttributeDef "ca" False cur
129+
cellfAssignsToName <- fromAttributeDef "bx" False cur
130+
cellfCalculate <- fromAttributeDef "ca" False cur
138131
t <- fromAttributeDef "t" defaultFormulaType cur
139-
(_cellfExpression, shared) <-
132+
(cellfExpression, shared) <-
140133
case t of
141134
d | d == defaultFormulaType -> do
142135
formula <- fromCursor cur
@@ -172,12 +165,12 @@ instance ToElement CellFormula where
172165
commonAttrs =
173166
M.fromList $
174167
catMaybes
175-
[ "bx" .=? justTrue _cellfAssignsToName,
176-
"ca" .=? justTrue _cellfCalculate,
168+
[ "bx" .=? justTrue cellfAssignsToName,
169+
"ca" .=? justTrue cellfCalculate,
177170
"t" .=? justNonDef defaultFormulaType fType
178171
]
179172
(formulaEl, fType) =
180-
case _cellfExpression of
173+
case cellfExpression of
181174
NormalFormula f -> (toElement nm f, defaultFormulaType)
182175
SharedFormula si -> (leafElement nm ["si" .= si], "shared")
183176

pub/xlsx/src/Codec/Xlsx/Types/Internal/FormulaData.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ instance FromXenoNode FormulaData where
5050
unexpected -> Left $ "Unexpected formula type" <> T.pack (show unexpected)
5151
let f =
5252
CellFormula
53-
{ _cellfAssignsToName = bx,
54-
_cellfCalculate = ca,
55-
_cellfExpression = expr
53+
{ cellfAssignsToName = bx,
54+
cellfCalculate = ca,
55+
cellfExpression = expr
5656
}
5757
return $ FormulaData f shared

pub/xlsx/src/Codec/Xlsx/Types/Internal/SharedStringTable.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ sstConstruct =
9898
SharedStringTable . V.fromList . uniq . concatMap goSheet
9999
where
100100
goSheet :: Worksheet -> [XlsxText]
101-
goSheet = mapMaybe (_cellValue >=> sstEntry) . Map.elems . _wsCells
101+
goSheet = mapMaybe (cellValue >=> sstEntry) . Map.elems . _wsCells
102102

103103
sstEntry :: CellValue -> Maybe XlsxText
104104
sstEntry (CellText text) = Just $ XlsxText text

pub/xlsx/src/Codec/Xlsx/Types/Table.hs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
{-# LANGUAGE DeriveGeneric #-}
33
{-# LANGUAGE OverloadedStrings #-}
44
{-# LANGUAGE RecordWildCards #-}
5-
{-# LANGUAGE TemplateHaskell #-}
65

76
module Codec.Xlsx.Types.Table where
87

@@ -83,8 +82,6 @@ data TableColumn = TableColumn
8382

8483
instance NFData TableColumn
8584

86-
makeLenses ''Table
87-
8885
{-------------------------------------------------------------------------------
8986
Parsing
9087
-------------------------------------------------------------------------------}

pub/xlsx/src/Codec/Xlsx/Writer.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ sheetDataXml rows rh sharedFormulas =
244244
formula = xlsxCellFormula cell
245245
fEl0 = toElement "f" <$> formula
246246
fEl <- case formula of
247-
Just CellFormula {_cellfExpression = SharedFormula si} -> do
247+
Just CellFormula {cellfExpression = SharedFormula si} -> do
248248
shared <- get
249249
case M.lookup si shared of
250250
Just fOpts -> do
@@ -569,7 +569,7 @@ transformSheetData shared ws = map transformRow $ toRows (ws ^. wsCells)
569569
transformRow = second (map transformCell)
570570
transformCell (c, Cell {..}) =
571571
( c,
572-
XlsxCell _cellStyle (fmap transformValue _cellValue) _cellComment _cellFormula
572+
XlsxCell cellStyle (fmap transformValue cellValue) cellComment cellFormula
573573
)
574574
transformValue (CellText t) = XlsxSS (sstLookupText shared t)
575575
transformValue (CellDouble dbl) = XlsxDouble dbl

pub/xlsx/src/Codec/Xlsx/Writer/Internal/PivotTable.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ generateCache cm PivotTable {..} =
164164
}
165165
((r1, c1), (r2, c2)) =
166166
fromJustNote "Invalid src ref of pivot table " $ fromRange _pvtSrcRef
167-
getCellValue ix = M.lookup ix cm >>= _cellValue
167+
getCellValue ix = M.lookup ix cm >>= cellValue
168168
itemsByName =
169169
M.fromList $
170170
flip mapMaybe [c1 .. c2] $ \c -> do

0 commit comments

Comments
 (0)