I'm defining a monadic observable/reactive parser. This behaves quite differently to a normal parser as it is a continuous query. The underlying type is:
IObservable<'a> -> IObservable<'b>
From looking at various parser implementations in functional languages, it seems as though the more appropriate way to define things is a single case discriminated union:
type Pattern<'a,'b> = Pattern of (IObservable<'a> -> IObservable<'b>)
Which means I then need to extract the underlying function to use it:
let find (Pattern p) = p
The question is: Is this just by convention, or for purposes of later extension, or is there a reason to do this even if the definition never changes?
Bonus question: If it's just for a more convenient type signature, why not just use a type alias:
type Pattern<'a,'b> = IObservable<'a> -> IObservable<'b>
I've advanced quite a way through this, and haven't found a case where composability is affected by not using the DU.