Skip to content

Idiomatic solution preventing unification / Pattern matching on sum-types #3632

Answered by myitcv
loisch asked this question in Q&A
Discussion options

You must be logged in to vote

@loisch thanks for the detailed context. Very interesting!

Reducing down the original declaration of #rk:

#rk: {
	CompleteWard: null
} | {
	PartialWard: string
}

#rk: {
	orgSyntax!: string
}

#rk: {
	CompleteWard: null
	orgSyntax:    "CompleteWard"
} | {
	PartialWard: string
	orgSyntax:   "PartialWard"
}

Using cue eval we can see this results in:

#rk: {
    CompleteWard: null
    orgSyntax:    "CompleteWard"
} | {
    CompleteWard: null
    orgSyntax:    "PartialWard"
    PartialWard:  string
} | {
    PartialWard:  string
    orgSyntax:    "CompleteWard"
    CompleteWard: null
} | {
    PartialWard: string
    orgSyntax:   "PartialWard"
}

This is, I suspect, not what you were expectin…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@myitcv
Comment options

Answer selected by loisch
@loisch
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants