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

[ bsd3, development, library ] [ Propose Tags ]

See for more information and for examples.

[Skip to Readme]
Versions [faq],,,
Change log
Dependencies base (>=4.7 && <5), constraints-extras (>=0.3), dependent-hashmap (>=0.1), dependent-sum (>=0.6), dependent-sum-template, deriving-compat (>=0.5), hashable (>=1.3), lifted-base (>=0.2), monad-control (>=1.0), mtl (>=2.2), rock, transformers (>=0.5), transformers-base (>=0.4), unordered-containers (>=0.2) [details]
License BSD-3-Clause
Copyright 2018-2020 Olle Fredriksson
Author Olle Fredriksson
Category Development
Home page
Source repo head: git clone
Uploaded by OlleFredriksson at 2020-06-28T22:07:05Z
Distributions NixOS:
Executables rock-spreadsheet
Downloads 830 total (8 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs available [build log]
Last success reported on 2020-06-28 [all 1 reports]


[Index] [Quick Jump]



"Build examples"


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


Maintainer's Corner

For package maintainers and hackage trustees

Readme for rock-

[back to package description]

rock Build Status Hackage

A build system inspired by Build systems à la carte.

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


{-# language FlexibleInstances #-}
{-# language GADTs #-}
{-# language StandaloneDeriving #-}
{-# language TemplateHaskell #-}

import Control.Monad.IO.Class
import Data.GADT.Compare.TH (deriveGEq)
import Data.Hashable
import Data.Some
import Data.IORef
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

instance Hashable (Query a) where
  hashWithSalt salt query =
    case query of
      A -> hashWithSalt salt (0 :: Int)
      B -> hashWithSalt salt (1 :: Int)
      C -> hashWithSalt salt (2 :: Int)
      D -> hashWithSalt salt (3 :: Int)

instance Hashable (Some Query) where
  hashWithSalt salt (Some query) = hashWithSalt salt query

rules :: Rock.Rules Query
rules key = do
  liftIO $ putStrLn $ "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
    liftIO $ putStrLn "Running"
    result <- Rock.runTask rules (Rock.fetch D)
    print result
    liftIO $ putStrLn "Running with memoisation"
    memoVar <- newIORef mempty
    result <- Rock.runTask (Rock.memoise memoVar rules) (Rock.fetch D)
    liftIO $ print result


Fetching D
Fetching B
Fetching A
Fetching C
Fetching A
Running with memoisation
Fetching D
Fetching B
Fetching A
Fetching C

Related projects


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