Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
252 changes: 163 additions & 89 deletions .github/workflows/haskell-ci.yml

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ dataframe_benchmark/
bin/
coverage-html
.DS_Store
flake.lock
tags
__pycache__
venv
Expand All @@ -45,4 +44,4 @@ Cargo.lock
# (transient; the committed *.db fixtures themselves stay tracked).
*.db-wal
*.db-shm
*.db-journal
*.db-journal
1 change: 1 addition & 0 deletions cabal.project.ci
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
packages:
.
dataframe-core
dataframe-expr-serializer
dataframe-parsing
dataframe-operations
dataframe-csv
Expand Down
16 changes: 10 additions & 6 deletions dataframe-operations/src/DataFrame/Monad.hs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ instance Functor Pipeline where
fmap f (Pipeline g) = Pipeline $ \n -> let (n', w, a) = g n in (n', w, f a)

instance Applicative Pipeline where
pure x = Pipeline (, [], x)
pure x = Pipeline (,[],x)
Pipeline gf <*> Pipeline gx = Pipeline $ \n ->
let (n1, w1, f) = gf n
(n2, w2, x) = gx n1
Expand All @@ -128,7 +128,7 @@ instance Monad Pipeline where

-- | Derive a column under an explicit name, returning a reference to it.
letAs :: (Columnable a) => T.Text -> Expr a -> Pipeline (Expr a)
letAs nm e = Pipeline (, [(nm, UExpr e)], Col nm)
letAs nm e = Pipeline (,[(nm, UExpr e)],Col nm)

-- | Derive a column under a fresh generated name.
letExpr :: (Columnable a) => Expr a -> Pipeline (Expr a)
Expand All @@ -138,8 +138,11 @@ letExpr e = Pipeline $ \n ->
instance Show (Pipeline (Expr a)) where
show p =
let (_, steps, res) = unPipeline p 0
in concatMap (\(nm, UExpr e) -> T.unpack nm ++ " = " ++ prettyPrint e ++ "\n") steps
++ "return " ++ prettyPrint res
in concatMap
(\(nm, UExpr e) -> T.unpack nm ++ " = " ++ prettyPrint e ++ "\n")
steps
++ "return "
++ prettyPrint res

-- | Number of column derivations the pipeline performs.
pipelineSteps :: Pipeline a -> Int
Expand All @@ -151,7 +154,8 @@ toFrameM p =
let (_, steps, res) = unPipeline p 0
in mapM_ (\(nm, UExpr e) -> void (deriveM nm e)) steps >> pure res

-- | Run a pipeline over a frame: derive its columns and return the result
-- expression (a reference to the final column) and the resulting frame.
{- | Run a pipeline over a frame: derive its columns and return the result
expression (a reference to the final column) and the resulting frame.
-}
runPipeline :: DataFrame -> Pipeline (Expr a) -> (Expr a, DataFrame)
runPipeline df = runFrameM df . toFrameM
2 changes: 1 addition & 1 deletion examples/examples.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ executable examples
cassava >= 0.1 && < 1,
containers >= 0.6.7 && < 0.9,
directory >= 1.3.0.0 && < 2,
granite ^>= 0.6,
granite >= 0.6 && < 1,
hashable >= 1.2 && < 2,
hasktorch,
http-conduit,
Expand Down
194 changes: 194 additions & 0 deletions flake.lock

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

flake.lock tracks hashes of inputs like nixpkgs to make sure people using nix build with the same package sets. It's an essential file to be in version control.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading