@@ -19,6 +19,23 @@ module Extensions =
1919 let ( ClosedBinaryOp f ) = this
2020 QuotationEvaluator.Evaluate f
2121
22+ module CustomDatatypes =
23+ [<Struct>]
24+ type WrappedInt = { InnerValue: int }
25+ with
26+ static member (+) ( x : WrappedInt , y : WrappedInt ) = { InnerValue = x.InnerValue + y.InnerValue }
27+ static member (*) ( x : WrappedInt , y : WrappedInt ) = { InnerValue = x.InnerValue * y.InnerValue }
28+
29+ let addMultSemiringOnWrappedInt : Semiring < WrappedInt > =
30+ {
31+ PlusMonoid = {
32+ AssociativeOp = ClosedBinaryOp <@ (+) @>
33+ Identity = { InnerValue = 0 }
34+ }
35+
36+ TimesSemigroup = { AssociativeOp = ClosedBinaryOp <@ (*) @> }
37+ }
38+
2239module Generators =
2340 let logger = Log.create " Generators"
2441
@@ -185,6 +202,13 @@ module Generators =
185202 |> genericSparseGenerator false Arb.generate< bool>
186203 |> Arb.fromGen
187204
205+ static member WrappedInt () =
206+ pairOfMatrixAndVectorOfCompatibleSizeGenerator
207+ |> genericSparseGenerator
208+ CustomDatatypes.addMultSemiringOnWrappedInt.PlusMonoid.Identity
209+ Arb.generate< CustomDatatypes.WrappedInt>
210+ |> Arb.fromGen
211+
188212 type PairOfSparseVectorAndMatrixOfCompatibleSize () =
189213 static let pairOfVectorAndMatrixOfCompatibleSizeGenerator ( valuesGenerator : Gen < 'a >) = gen {
190214 let! ( nrows , ncols ) = dimension2DGenerator
0 commit comments