Defines a Fact
, using the name of the val
it is assigned to as the name of the Fact
.
Defines a Fact
, using the name of the val
it is assigned to as the name of the Fact
. Note: the value of this
macro *must* be assigned to a val
, otherwise a compiler error will be raised.
the value type of the resulting Fact
.
a SingularFact
initialized with the name of the val declaration.
Defines a Fact
, using the name of the val
it is assigned to as the name of the Fact
.
Defines a Fact
, using the name of the val
it is assigned to as the name of the Fact
. Note: the value of this
macro *must* be assigned to a val
, otherwise a compiler error will be raised.
the value type of the resulting Fact
.
description of the Fact
, to be passed along to the Fact
's constructor.
a SingularFact
initialized with the name of the val declaration.
Defines a Fact
, using the name of the val
it is assigned to as the name of the Fact
.
Defines a Fact
, using the name of the val
it is assigned to as the name of the Fact
. Note: the value of this
macro *must* be assigned to a val
, otherwise a compiler error will be raised.
the value type of the resulting Fact
.
a ListFact
initialized with the name of the val declaration.
Defines a Fact
, using the name of the val
it is assigned to as the name of the Fact
.
Defines a Fact
, using the name of the val
it is assigned to as the name of the Fact
. Note: the value of this
macro *must* be assigned to a val
, otherwise a compiler error will be raised.
the value type of the resulting Fact
.
description of the Fact
, to be passed along to the Fact
's constructor.
a ListFact
initialized with the name of the val declaration.
FactMacros
contains two compile-time macros which allow the easy creation of aFact
, without having to explicitly repeat the name of theFact
as an argument. This makes it easier to define Facts for use in a DSL, as the name of the val to which it is assigned, becomes the name of theFact
itself.Without these macros, you would need to create
Fact
s as follows:val MyFact = new SingularFact[Int]("MyFact")
This redundancy of the
Fact
's name is not just a nuisance to type, it actually causes trouble when renaming theFact
, or trying to copy its declaration. In both situations, you *must* also alter the name parameter manually. The compiler and IDE tooling cannot help you track these errors down and so you are bound to find out about them at runtime, with potentially uninformative error messages.If instead, you use these macros, these troubles will be taken away. Define your
Fact
s like this and have the IDE and compiler warn you about duplicate names etc:val MyFact = FactMacros.defineFact[Int]("Description")