i-am-tom / dagmore

Less Type, more Typeable.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dagmore ๐Ÿ• โ›‘

She was like a candle in the wind... unreliable. - Dean Learner

Dagmore is a DSL for constructing heterogenous computations representable as DAGs. It bears a lot of similarity to Dagless, its spiritual older brother, but uses rank-2 polymorphism to provide similar guarantees without the compile-time overhead or IxMonad/do-notation trickery!


See the Test directory for fully-worked examples!

main = run do
  acceleration <- fetch @Acceleration
  mass         <- fetch @Mass
  displacement <- fetch @Displacement

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

    pure (Force (m' * a'))

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

    pure (Energy (f' * d'))

About

Less Type, more Typeable.

License:MIT License


Languages

Language:Haskell 100.0%