mirror of
https://github.com/logos-storage/questionable.git
synced 2026-01-02 13:53:11 +00:00
22 lines
555 B
Nim
22 lines
555 B
Nim
import ./private/scope
|
|
|
|
template liftUnary*(T: type, operator: untyped) =
|
|
|
|
template `operator`*(a: T): untyped =
|
|
scope:
|
|
let evaluated = a
|
|
evaluated ->? `operator`(evaluated.unsafeGet())
|
|
|
|
template liftBinary*(T: type, operator: untyped) =
|
|
|
|
template `operator`*(a: T, b: T): untyped =
|
|
scope:
|
|
let evalA = a
|
|
let evalB = b
|
|
(evalA, evalB) ->? `operator`(evalA.unsafeGet, evalB.unsafeGet)
|
|
|
|
template `operator`*(a: T, b: typed): untyped =
|
|
scope:
|
|
let evalA = a
|
|
evalA ->? `operator`(evalA.unsafeGet(), b)
|