-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
This is a possible way to implement sealed traits (or the equivalent) without anything more than the module system.
data HiddenBoolean = a
export data True
export data False
export let trueHiddenBoolean = HiddenBoolean True
export let falseHiddenBoolean = HiddenBoolean False
export data Boolean = implicit HiddenBoolean a -> a
Externally, you would use the Boolean data type to require a boolean value of either True or False. The fact that HiddenBoolean is not exported prevents anyone from creating more instances of it.
Reactions are currently unavailable