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
@@ -157,19 +162,24 @@ that can be subject to constraints. The system comes with a large set of `HasSpe
157
162
158
163
## HasSpec instances
159
164
160
-
`HasSpec` instances can always be added to admit more types.Anytype with a `GHC.Generics(Generic)` instance can be
161
-
given a default instance by using its Sum-of-Products generic definition.In the CardanoLedgerSystem
162
-
over 200 types in the Ledger code base have been given `HasSpec` instances, either by using the `GHC.Generics` path, or by writing the instances by hand.
165
+
`HasSpec` instances can always be added to admit more types.Anytype with a
166
+
`Generic` instance can be given a default instance by using its generic
167
+
definition - provided that the types it uses have `HasSpec` instances.In the
168
+
CardanoLedgerSystem over 200 types in the Ledger code base have been given
169
+
`HasSpec` instances, either by using the `GHC.Generics` path, or by writing the
170
+
instances by hand (more on this later).
163
171
164
172
## Building logic specifications using Haskell functions
165
173
166
-
Note that `constrained`and`match`take functions, which abstract over terms, andreturn `Specification` and `Pred`.
167
-
Using the library functions, variables in the Term language are always introduced using Haskell lambda abstractions.And the library
168
-
functions combine these into Terms, Preds, andSpecifications.
174
+
Note that `constrained`and`match`take functions, which abstract over terms,
175
+
andreturn `Specification` and `Pred`.Using the library functions, variables
176
+
in the Term language are always introduced using Haskell lambda abstractions.
177
+
And the library functions combine these into Terms, Preds, andSpecifications.
169
178
170
179
## Another example using conjunction and simple arithmetic
171
180
172
-
Suppose we want to put more than one simple condition on the pair ofInts.We would do that using the connective `And` that converts a `[Pred]` into a `Pred`
181
+
Suppose we want to put more than one simple condition on the pair ofInts.We
182
+
would do that using the connective `And` that converts a `[Pred]` into a `Pred`
173
183
174
184
```haskell
175
185
sumPair::Specification (Int, Int)
@@ -183,7 +193,7 @@ sumPair = constrained $ \p ->
183
193
```
184
194
185
195
This example also re-illustrates that `(Term Int)` has a (partial) Num instance, and that we can constrain
186
-
multiple (different) variables using simple `Num` methods (`(+)`, `(-)`, and `negate`). Note also
196
+
multiple (different) variables using simple `Num` methods (`(+)`, `(-)`, `(*)`, and `negate`). Note also
187
197
the operator: `(==.) :: (Eq n, HasSpec n) => Term n -> Term n -> Term Bool`
0 commit comments