Skip to content

Commit 6ca55b4

Browse files
committed
feat: Remove NFData instance from Columnable
Messes with persistent.
1 parent 99a4a88 commit 6ca55b4

File tree

9 files changed

+11
-23
lines changed

9 files changed

+11
-23
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
strategy:
1313
fail-fast: false
1414
matrix:
15-
ghc: ["9.4.8", "9.6.7", "9.8.4", "9.10.3", "9.12.2"]
15+
ghc: ["9.6.7", "9.8.4", "9.10.3", "9.12.2"]
1616

1717
steps:
1818
- uses: actions/checkout@v4

examples/Iris.lhs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ Think of these like compiler flags in C++ or decorator syntax in Python:
2626
> {-# LANGUAGE OverloadedStrings #-}
2727
> {-# LANGUAGE RecordWildCards #-}
2828
> {-# LANGUAGE TypeApplications #-}
29-
> {-# LANGUAGE DeriveAnyClass #-}
3029
>
3130
> module Iris (run) where
3231

@@ -45,7 +44,6 @@ in Python or `#include` in C++:
4544
> import qualified Data.Text as T
4645
> import qualified Data.Vector as V
4746
> import qualified Data.Vector.Unboxed as VU
48-
> import Control.DeepSeq
4947
> import GHC.Generics
5048

5149
DataFrame is a Haskell library similar to pandas in Python:
@@ -73,7 +71,7 @@ as an algebraic data type (similar to an enum in other languages):
7371
> = Setosa
7472
> | Versicolor
7573
> | Virginica
76-
> deriving (Eq, Show, Read, Ord, Enum, Generic, NFData)
74+
> deriving (Eq, Show, Read, Ord, Enum)
7775

7876
The `deriving` clause automatically generates useful functions:
7977
- `Eq`: Allows us to compare Iris values for equality

scripts/presubmit.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ set -e
88
cabal build
99
cabal test
1010

11-
cd examples
12-
13-
cabal build all
14-
1511
cd ../dataframe-persistent
1612

1713
cabal build
1814

1915
cd ../dataframe-hasktorch
2016

2117
cabal build
18+
19+
cd examples
20+
21+
cabal build all

src/DataFrame/IO/CSV.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import qualified Data.Vector.Unboxed.Mutable as VUM
2727
import Data.Csv.Streaming (Records (..))
2828
import qualified Data.Csv.Streaming as CsvStream
2929

30+
import Control.DeepSeq
3031
import Control.Monad
3132
import Data.Char
3233
import qualified Data.Csv as Csv
@@ -272,7 +273,7 @@ readSeparated :: ReadOptions -> FilePath -> IO DataFrame
272273
readSeparated opts !path = do
273274
let stripUtf8Bom bs = fromMaybe bs (BL.stripPrefix "\xEF\xBB\xBF" bs)
274275
csvData <- stripUtf8Bom <$> BL.readFile path
275-
decodeSeparated opts csvData
276+
fmap force (decodeSeparated opts csvData)
276277

277278
decodeSeparated :: ReadOptions -> BL.ByteString -> IO DataFrame
278279
decodeSeparated !opts csvData = do

src/DataFrame/Internal/Column.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ instance (Show a) => Show (TypedColumn a) where
134134
show (TColumn col) = show col
135135

136136
instance NFData Column where
137-
rnf (BoxedColumn (v :: VB.Vector a)) = rnf v
137+
rnf (BoxedColumn (v :: VB.Vector a)) = VB.foldl' (const (`seq` ())) () v
138138
rnf (UnboxedColumn v) = v `seq` ()
139-
rnf (OptionalColumn (v :: VB.Vector (Maybe a))) = rnf v
139+
rnf (OptionalColumn (v :: VB.Vector (Maybe a))) = VB.foldl' (const (`seq` ())) () v
140140

141141
instance Show Column where
142142
show :: Column -> String

src/DataFrame/Internal/Expression.hs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
module DataFrame.Internal.Expression where
1515

16-
import Control.DeepSeq (NFData (..))
1716
import Data.String
1817
import qualified Data.Text as T
1918
import Data.Type.Equality (TestEquality (testEquality), type (:~:) (Refl))
@@ -38,9 +37,6 @@ data BinaryOp a b c = MkBinaryOp
3837
data MeanAcc = MeanAcc {-# UNPACK #-} !Double {-# UNPACK #-} !Int
3938
deriving (Show, Eq, Ord, Read)
4039

41-
instance NFData MeanAcc where
42-
rnf (MeanAcc _ _) = ()
43-
4440
data AggStrategy a b where
4541
CollectAgg ::
4642
(VG.Vector v b, Typeable v) => T.Text -> (v b -> a) -> AggStrategy a b

src/DataFrame/Internal/Row.hs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import qualified Data.Vector.Algorithms.Merge as VA
1717
import qualified Data.Vector.Generic as VG
1818
import qualified Data.Vector.Unboxed as VU
1919

20-
import Control.DeepSeq (NFData (..))
2120
import Control.Exception (throw)
2221
import Control.Monad.ST (runST)
2322
import Data.Function (on)
@@ -58,9 +57,6 @@ instance Show Any where
5857
show :: Any -> String
5958
show (Value a) = T.unpack (showValue a)
6059

61-
instance NFData Any where
62-
rnf (Value a) = rnf a
63-
6460
showValue :: forall a. (Columnable a) => a -> T.Text
6561
showValue v = case testEquality (typeRep @a) (typeRep @T.Text) of
6662
Just Refl -> v

src/DataFrame/Internal/Types.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,13 @@
1313

1414
module DataFrame.Internal.Types where
1515

16-
import Control.DeepSeq (NFData)
1716
import Data.Int (Int16, Int32, Int64, Int8)
1817
import Data.Kind (Constraint, Type)
1918
import Data.Typeable (Typeable)
2019
import qualified Data.Vector.Unboxed as VU
2120
import Data.Word (Word16, Word32, Word64, Word8)
2221

23-
type Columnable' a = (Typeable a, Show a, Ord a, Eq a, Read a, NFData a)
22+
type Columnable' a = (Typeable a, Show a, Ord a, Eq a, Read a)
2423

2524
{- | A type with column representations used to select the
2625
"right" representation when specializing the `toColumn` function.

tests/Operations/Provenance.hs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33

44
module Operations.Provenance where
55

6-
import qualified Data.List as L
76
import qualified Data.Map as M
8-
import qualified Data.Text as T
97
import qualified DataFrame as D
108
import qualified DataFrame.Functions as F
119
import qualified DataFrame.Internal.Column as DI

0 commit comments

Comments
 (0)