Skip to content

Commit b9dedff

Browse files
author
Will Kimmerer
committed
extend addop and mulop
1 parent dadfc6d commit b9dedff

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

src/operators/oplist.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,8 @@ for oplus ∈ [(:max, "MAX"), (:min, "MIN"), (:+, "PLUS"), (:*, "TIMES"), (:any,
767767
rig = Symbol(oplus[2], "_", otimes[2])
768768
funcquote = quote
769769
Semirings.Semiring(::typeof($(oplus[1])), ::typeof($(otimes[1]))) = $rig
770+
addop(::typeof($rig)) = $(oplus[1])
771+
mulop(::typeof($rig)) = $(otimes[1])
770772
end
771773
@eval($funcquote)
772774
end

src/operators/semirings.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,8 @@ function Semirings.Semiring(name::String, add::AbstractMonoid, mul::AbstractBina
280280
tmul = validtypes(mul)
281281
trig = intersect(tadd, tmul)
282282
rig = Semirings.Semiring(name)
283+
eval(:(addop(::typeof($rig)) = juliaop($(add))))
284+
eval(:(mulop(::typeof($rig)) = juliaop($(mul))))
283285
for t trig
284286
_addsemiring(rig, add[t], mul[t])
285287
end

0 commit comments

Comments
 (0)