Hey folks,
Another question about how to properly use concepts. This time, I'm trying to reference a concept within a generic... within a concept.
This is what I'm trying to achieve:
import options
type
Obj = concept o
`==`(o, o) is bool
Container = concept c
var opt: Option[Obj]
test(c, opt) is bool
type
MyObj = tuple[x, y: int]
MyContainer = object
data: int
proc test( c: MyContainer, opt: Option[MyObj] ): bool = true
if MyObj is Obj:
echo "MyObj is Obj"
if MyContainer is Container:
echo "MyContainer is Container"
I also tried this:
import options
type
Obj = concept o
`==`(o, o) is bool
Container[T] = concept c
var opt: Option[T]
test(c, opt) is bool
type
MyObj = tuple[x, y: int]
MyContainer = object
data: int
proc test( c: MyContainer, opt: Option[MyObj] ): bool = true
if MyObj is Obj:
echo "MyObj is Obj"
if MyContainer is Container[MyObj]:
echo "MyContainer is Container"
In both cases, I would expect that final "echo" statement to execute, but it doesn't. If I remove the reference to Option, but the way, it works as expected.
Any ideas around how to represent this?
There are several open issues about concepts on github: https://github.com/nim-lang/Nim/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+concept I didn't check all the examples, but your case might look similar to one of these. For the Option object, there is a Concept[T] github tag.
I know that this doesn't solve your problem, but it might link you to some useful comments.
Peter