Closed mortehu closed 3 years ago
DEFINE_VARIANT is briefly described in reflect.H:
DEFINE_VARIANT
reflect.H
A macro 'DEFINE_VARIANT(T, (cn0, T0), ... (cnN, TN))' is included to be equivalent to '|cn0:T0, ..., cnN:TN|'
However, I'm having trouble using types defined using DEFINE_VARIANT without getting "Unsatisfiable predicate" errors. Here's my attempt:
#include <iostream> #include "hobbes/hobbes.H" using FooSum = hobbes::variant<int, float>; DEFINE_VARIANT(FooVariant, (A, int), (B, float)); int main(int argc, char** argv) { hobbes::cc cc; // Ok cc.compileFn<int(FooSum*)>("foo", "match foo with | |0=a| -> a | _ -> 0"); // Ok cc.define("bar", "|A=1| :: |A:int, B:float|"); cc.compileFn<int()>("match bar with | |A=a| -> a | _ -> 0"); // Prints "|A=1|" std::cerr << FooVariant::A(1) << std::endl; // Prints "stdin:1,1-36: Unsatisfiable predicate: |A:int|::<FooVariant>" cc.compileFn<int(FooVariant*)>("foo", "match foo with | |A=a| -> a | _ -> 0"); }
Thank you for reporting this; it appears to be a bug in Hobbes wherein the compileFn isn't prepared to lift these kinds of variant types.
compileFn
DEFINE_VARIANT
is briefly described inreflect.H
:However, I'm having trouble using types defined using
DEFINE_VARIANT
without getting "Unsatisfiable predicate" errors. Here's my attempt: