I followed the manual as for how to use higher-kinded concepts. I was quite surprised when the code containing genericHead actually compiled, but returned something I don't really get...
import future, typetraits, options
type Functor[A] = concept f
f.get is A
echo Option[int] is Functor # prints true
import future, typetraits, options
type Functor[A] = concept f
f.get is A
type MatchedGenericType = genericHead(f.type)
type T = auto
map(f, A -> T) is MatchedGenericType[T]
echo Option[int] is Functor # prints false
So I checked...
import options
type MyOption = genericHead(Option[int]) # type expected
Ok, so I'm supposed to instantiate the higher-order type. No problem.
import options
type StrOption = genericHead(Option[int])[string] # no generic parameters allowed for T
Ok... So maybe I'll use stripGenericParams?
import options
type StrOption = stripGenericParams(Option[int])[string]
echo StrOption() # prints: None[string]
Perfect. Now make it generic and add to the concept:
import future, typetraits
type Functor[A] = concept f
f.get is A
type MatchedGenericType[T] = stripGenericParams(f.type)[T]
echo Option[int] is Functor # prints true
Nice. Now add the map...
import future, typetraits
type Functor[A] = concept f
f.get is A
type MatchedGenericType[T] = stripGenericParams(f.type)[T]
type T = auto
map(f, A -> T) is MatchedGenericType[T]
echo Option[int] is Functor # prints false
Ok, no I have no idea what happened. {.explain.} doesn't seem to work either...
Does anyone have any idea what's going on?