For building DSLs that allow the composition of pure and fully type-safe expressions such that any sub-expression may generate or receive errors as input, short-circuiting evaluation.
resolvers ++= Seq(
"jitpack" at "https://jitpack.io"
)
libraryDependencies ++= Seq(
"com.github.ryanonsrc" %% "espresso" % "v1.0.0"
)
espresso makes extensive use of the Typelevel cats and shapeless libraries as well as the kind-projector compiler plugin.
Take a look at https://github.com/ryanonsrc/espresso/tree/master/src/test/scala/io/nary/espresso/sample
Term[E, A]
- Represents a term within an expression, evaluating to an error of typeE
or result of typeA
Expr[E, A, B]
- For any expression taking a value of typeA
and evaluating to either a result of typeB
or an error of typeE
In[E, A]
- Input that can be "read" into an expression as either value of typeA
or an error of typeE
opN
- Lift a function f: (HList ofN
terms ⇒Term[E, B]
) into aExpr[E, A1 :: ... :: AN :: HNil, B]
joinN
- Combine an Hlist ofN
expressions:Expr[E, A, Bi]
into a singleExpr[E, A, B1 :: ... :: BN :: HNil]
evalN
- GivenN
expressions:Expr[E, A, Bi]
and operation:Expr[E, B1 :: ... :: BN :: HNil, C]
, generateExpr[E, A, C]