Monthly Downloads: 10
Programming language: Haskell
License: BSD 3-clause "New" or "Revised" License
Tags: Development    
Latest version: v0.3.1.1

rock alternatives and similar packages

Based on the "Development" category.
Alternatively, view rock alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of rock or a related project?

Add another 'Development' Package


rock Build Status Hackage

A build system inspired by Build systems à la carte.

Used in Sixten, Sixty and Eclair 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

Note: Besides pure computations as shown above, the Task data type implements MonadIO, so you can lift IO actions into the Task monad by using liftIO!

Query parameters

If you need to parametrize your queries (e.g. typechecking one specific file), you can do this by adding additional arguments to your Query datatype:

data Query a where
  Parse :: FilePath -> Query AST
  Typecheck :: FilePath -> Query (Either TypeError TypedAST)

rules :: Rock.Rules Query
rules key = case key of
  Parse file -> do
    _ -- parse the file..
  Typecheck file -> do
    ast <- Rock.fetch (Parse file)
    _ -- typecheck file..

Related projects


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