rock: A build system for incremental, parallel, and demand-driven computations

[ bsd3, development, library ] [ Propose Tags ]

See https://www.github.com/ollef/rock for more information and https://github.com/ollef/rock/tree/master/examples for examples.


[Skip to Readme]
Versions [faq] 0.1.0.0, 0.1.0.1
Change log CHANGELOG.md
Dependencies base (>=4.7 && <5), dependent-map, dependent-sum, dependent-sum-template, deriving-compat, mtl, protolude, rock, transformers [details]
License BSD-3-Clause
Copyright 2018-2019 Olle Fredriksson
Author Olle Fredriksson
Maintainer fredriksson.olle@gmail.com
Category Development
Home page https://github.com/ollef/rock#readme
Source repo head: git clone https://github.com/ollef/rock
Uploaded by OlleFredriksson at Mon Jul 1 21:50:56 UTC 2019
Distributions NixOS:0.1.0.1
Executables rock-spreadsheet
Downloads 69 total (16 in the last 30 days)
Rating (no votes yet) [estimated by rule of succession]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs available [build log]
Last success reported on 2019-07-01 [all 1 reports]

Modules

[Index] [Quick Jump]

Flags

NameDescriptionDefaultType
examples

"Build examples"

DisabledManual

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info

Downloads

Maintainer's Corner

For package maintainers and hackage trustees


Readme for rock-0.1.0.1

[back to package description]

rock Hackage

A build system inspired by Build systems à la carte and Haxl.

Used in Sixten and Sixty to achieve incremental and query driven compiler architectures.

Example

{-# language GADTs #-}
{-# language NoImplicitPrelude #-}
{-# language OverloadedStrings #-}
{-# language StandaloneDeriving #-}
{-# language TemplateHaskell #-}

import Protolude

import Data.GADT.Compare.TH (deriveGEq, deriveGCompare)
import qualified Rock

data Query a where
  A :: Query Integer
  B :: Query Integer
  C :: Query Integer
  D :: Query Integer

deriving instance Show (Query a)

deriveGEq ''Query
deriveGCompare ''Query

rules :: Rock.Rules Query
rules key = do
  putText $ "Fetching " <> show key
  case key of
    A -> pure 10
    B -> do
      a <- Rock.fetch A
      pure $ a + 20
    C -> do
      a <- Rock.fetch A
      pure $ a + 30
    D ->
      (+) <$> Rock.fetch B <*> Rock.fetch C

main :: IO ()
main = do
  do
    putText "Running"
    result <- Rock.runTask Rock.sequentially rules (Rock.fetch D)
    print result
  do
    putText "Running with memoisation"
    memoVar <- newMVar mempty
    result <-
      Rock.runTask
        Rock.sequentially
        (Rock.memoise memoVar rules)
        (Rock.fetch D)
    print result
  do
    putText "Running with memoisation using the parallel strategy"
    memoVar <- newMVar mempty
    result <-
      Rock.runTask
        Rock.inParallel
        (Rock.memoise memoVar rules)
        (Rock.fetch D)
    print result

Prints

Running
Fetching D
Fetching B
Fetching A
Fetching C
Fetching A
70
Running with memoisation
Fetching D
Fetching B
Fetching A
Fetching C
70
Running with memoisation using the parallel strategy
Fetching D
Fetching C
Fetching B
Fetching A
70

Related projects

Contributions

... are very welcome, especially in the areas of documentation, examples, testing, and benchmarking.