How to make indexed monad?

I am trying to get into scala’s new feature that is match type. In this code I attempted to make a recursion on a homogenous list that functions as a part of an indexed monad. In short, I want operations to write tags into this list, and read it to check if a given operation is allowed to operate on tagged values. Sadly I have stuck, and I need some help from mature scalists. :smiley:

Hi, welcome. To better help people understand what your topic is about, please give it a descriptive title, e.g. ‘How to do XYZ?’ Then people who might know the answer are more likely to notice your question, and jump into the thread to answer, instead of scrolling past it.