-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from LaurentRDC/frames
Prototype of dataframes based on higher-kinded types
- Loading branch information
Showing
11 changed files
with
934 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Revision history for javelin-frames | ||
|
||
## 0.1.0.0 -- YYYY-mm-dd | ||
|
||
* First version. Released on an unsuspecting world. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Copyright (c) 2025 Laurent Rene de Cotret | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included | ||
in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
{-# LANGUAGE DeriveAnyClass #-} | ||
{-# LANGUAGE TypeFamilies #-} | ||
|
||
import Control.DeepSeq ( NFData, rnf ) | ||
import Control.Exception ( evaluate ) | ||
import Criterion.Main ( bench, bgroup, nf, defaultMain ) | ||
|
||
import Data.Frame ( Column, Frameable, Indexable, Row, Frame ) | ||
import qualified Data.Frame as Frame | ||
import qualified Data.Vector as Vector | ||
|
||
import GHC.Generics ( Generic ) | ||
|
||
|
||
data Bench t | ||
= MkBench { field1 :: Column t Int | ||
, field2 :: Column t Int | ||
, field3 :: Column t Int | ||
, field4 :: Column t Int | ||
, field5 :: Column t Int | ||
, field6 :: Column t Int | ||
} | ||
deriving (Generic, Frameable) | ||
|
||
instance NFData (Row Bench) | ||
instance NFData (Frame Bench) | ||
|
||
instance Indexable Bench where | ||
type Key Bench = Int | ||
|
||
index = field1 | ||
|
||
|
||
main :: IO () | ||
main = do | ||
let rs = Vector.fromList [MkBench ix 0 0 0 0 0 | ix <- [0::Int .. 100_000]] | ||
fr = Frame.fromRows rs | ||
evaluate $ rnf rs | ||
evaluate $ rnf fr | ||
defaultMain | ||
[ bgroup "Row-wise operations" | ||
[ bench "fromRows" $ nf (Frame.fromRows) rs | ||
, bench "toRows" $ nf (Frame.toRows) fr | ||
, bench "toRows . fromRows" $ nf (Frame.fromRows . Frame.toRows) fr | ||
, bench "fromRows . toRows" $ nf (Frame.toRows . Frame.fromRows) rs | ||
] | ||
, bgroup "Lookups" | ||
[ bench "lookup" $ nf (Frame.lookup 100) fr | ||
, bench "ilookup" $ nf (Frame.ilookup 99) fr | ||
, bench "at" $ nf (`Frame.at` (100, field5)) fr | ||
, bench "iat" $ nf (`Frame.iat` (99, field5)) fr | ||
] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
cabal-version: 3.0 | ||
name: javelin-frames | ||
version: 0.1.0.0 | ||
synopsis: Type-safe data frames based on higher-kinded types. | ||
-- description: | ||
license: MIT | ||
license-file: LICENSE | ||
author: Laurent P. René de Cotret | ||
maintainer: [email protected] | ||
category: Data, Data Structures, Data Science | ||
build-type: Simple | ||
extra-doc-files: CHANGELOG.md | ||
tested-with: GHC ==9.12.1 | ||
|| ==9.10.1 | ||
|| ==9.8.4 | ||
|| ==9.6.4 | ||
|| ==9.4.8 | ||
|
||
description: | ||
|
||
This package implements data frames, a data structure | ||
where record types defined by the user can be transformed | ||
into records of columns. | ||
|
||
source-repository head | ||
type: git | ||
location: https://github.com/LaurentRDC/javelin | ||
|
||
common common | ||
default-language: GHC2021 | ||
ghc-options: -Wall | ||
-Wcompat | ||
-Widentities | ||
-Wincomplete-uni-patterns | ||
-Wincomplete-record-updates | ||
-Wredundant-constraints | ||
-fhide-source-paths | ||
-Wpartial-fields | ||
|
||
library | ||
import: common | ||
exposed-modules: Data.Frame | ||
Data.Frame.Tutorial | ||
build-depends: base >=4.15.0.0 && <4.22, | ||
containers >=0.6 && <0.8, | ||
vector >=0.12.3.0 && <0.14, | ||
hs-source-dirs: src | ||
default-language: GHC2021 | ||
|
||
test-suite javelin-frames-test | ||
import: common | ||
default-language: GHC2021 | ||
type: exitcode-stdio-1.0 | ||
hs-source-dirs: test | ||
main-is: Main.hs | ||
other-modules: Test.Data.Frame | ||
build-depends: base >=4.15.0.0 && <4.22, | ||
containers, | ||
hedgehog, | ||
javelin-frames, | ||
tasty, | ||
tasty-hedgehog, | ||
tasty-hunit, | ||
vector | ||
|
||
benchmark bench-frames | ||
import: common | ||
type: exitcode-stdio-1.0 | ||
ghc-options: -rtsopts | ||
hs-source-dirs: benchmarks | ||
main-is: Main.hs | ||
build-depends: base >=4.15.0.0 && <4.22, | ||
criterion ^>=1.6, | ||
deepseq, | ||
javelin-frames, | ||
vector |
Oops, something went wrong.