You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+18-13
Original file line number
Diff line number
Diff line change
@@ -2,11 +2,16 @@
2
2
3
3
Boilerplate free Tagless Final DSL macro annotation, written in [scala.meta](http://scalameta.org/) for future compatibility and other nice things (e.g. free IDE support, like in IntelliJ).
4
4
5
+
This library provides 2 macros:
6
+
7
+
1.[`@diesel`](#diesel) to make it easier to compose algebras together
8
+
2.[`@ktrans`](#ktrans) to make it easier to perform Kind transforms on interpreters.
9
+
5
10
## `@diesel`
6
11
7
12
The `@diesel` annotation that cuts out the boilerplate associated with writing composable Tagless Final DSLs.
8
13
9
-
The Dsl can be accessed directly from the companion object if you import a converter located in `ops`
14
+
The Dsl can be accessed directly from the companion object if you import a converter located in `ops`
10
15
(customisable by passing a name to the annotation as an argument). This are useful when you need to compose multiple DSLs in the context of `F[_]`, but do not want to name all the interpreter parameters.
11
16
12
17
### Example:
@@ -54,17 +59,17 @@ object DieselDemo {
54
59
55
60
}
56
61
/*
57
-
[info] Running DieselDemo
62
+
[info] Running DieselDemo
58
63
result 3
59
64
*/
60
65
```
61
66
62
67
For more in-depth examples, check out:
63
68
64
-
1.[examples/KVSApp](https://github.com/lloydmeta/diesel/blob/master/examples/src/main/scala/KVSApp.scala): a simple single-DSL program
69
+
1.[examples/KVSApp](https://github.com/lloydmeta/diesel/blob/master/examples/src/main/scala/KVSApp.scala): a simple single-DSL program
65
70
2.[examples/KVSLoggingApp](https://github.com/lloydmeta/diesel/blob/master/examples/src/main/scala/KVSLoggingApp.scala): composing 2 DSLs in a program
66
71
3.[examples/FibApp](https://github.com/lloydmeta/diesel/blob/master/examples/src/main/scala/FibApp.scala): composing 3 DSLs in a program that calculates fibonacci numbers and caches them.
67
-
72
+
68
73
All of the above examples use a pure KVS interpreter :)
69
74
70
75
### How it works
@@ -90,10 +95,10 @@ trait Maths[F[_]] {
90
95
objectMaths {
91
96
92
97
defapply[F[_]](implicitm: Maths[F]):Maths[F] = m
93
-
94
-
// In charge of aliasing your singleton Maths object to an in-scope Maths[F] :)
95
-
objectop {
96
-
implicitdeftoDsl[F[_]](o: Maths.type)(implicitm: Maths[F]):Maths[F] = m
98
+
99
+
// In charge of aliasing your singleton Maths object to an in-scope Maths[F] :)
100
+
objectop {
101
+
implicitdeftoDsl[F[_]](o: Maths.type)(implicitm: Maths[F]):Maths[F] = m
97
102
}
98
103
}
99
104
@@ -105,7 +110,7 @@ object Maths {
105
110
There is also a handy `@ktrans` annotation that adds a `transformK` method to a trait that is parameterised by a Kind that
106
111
takes 1 type parameter. It's useful when you want to transform any given implementation of that trait for `F[_]` into one
107
112
that implements it on `G[_]`
108
-
113
+
109
114
### Example
110
115
111
116
```scala
@@ -129,14 +134,14 @@ val MathsIdInterp = new Maths[Id] {
129
134
// Id to Option
130
135
validToOpt= λ[FunK[Id, Option]](Some(_))
131
136
132
-
// use the auto-generated transformK method to create a Maths[Option] from Maths[Id]
137
+
// use the auto-generated transformK method to create a Maths[Option] from Maths[Id]
0 commit comments