/dagless

A monadic interface for DAG construction.

Primary LanguageHaskellISC LicenseISC

Dagless 🕶 📚

The doors of Darkplace were opened. Not the literal doors of the building – most of which were closed – but evil doors, dark doors, doors to the beyond. Doors that were hard to shut because they were abstract, and didn't have handles. They were more like portals, really. From this day on, I'd have to fight these forces of darkness... and deal with the burden of day-to-day admin. - Dr. Rick Dagless, M.D.

Dagless is a DSL for constructing heterogenous computations representable as DAGs. Specifically, it uses an IxStateT transformer to keep track of updates to the graph. When combined with the fabulous do-notation package, however, this implementation detail is neatly hidden away!


See the Test directory for fully-worked examples!

main collection = compute' do
  mass         <- fetch @Mass
  acceleration <- fetch @Acceleration

  force <- using (mass, acceleration) $ \(m, a) -> do
    Mass         m' <- m
    Acceleration a' <- a

    pure (Force (m' * a'))

  displacement <- fetch @Displacement

  using (force, displacement) $ \(f, d) -> do
    Force        f' <- f
    Displacement d' <- d

    pure (Energy (f' * d'))