More generally you could use the merge function of mkOptionType, then use that type in the type option of mkOption. But yes, coercedTo would be the best option if there’s one type that you want everything to end up as.
Can you share an example of what you’d like the code to do? Let’s say I pass it a list containing an attrset and a function, like outputs = [ { a = 1; } (val: {a = val; }) ];, what should outputs contain at the end of this? (Or maybe you can explain what your usecase is and avoid x-y?)
I basically want options to accept any of a string, a path, an attribute set, a function returning an attribute set, or a list of the previous types, all of which will finally be mkMerged into a single attribute set. It seems easy enough, but defining a function type seems to be a little more complicated than I anticipated…
Sorry about that; got a bit confused myself. If a value passed to outputs is a function, is will be called with an inputs argument set, and should return an attribute set.
I kind of solved my problem by creating a isCoerced and isLambda function to check whether an outputs value is a function, so that I can put regular functors in my outputs if necessary, but I’m wondering if there’s a better way that will allow me to deal with these specific scenarios.