I'd like to know if there is any way to create a function that, given a list of namesnames/identifiersidentifiers e.g. [Monday, Tuesday, ...][Monday, Tuesday, ...], automatically creates a datatype day = Monday | Tuesday | ...datatype day = Monday | Tuesday | ... and a function next such that next Monday = Tuesdaynext Monday = Tuesday, next Tuesday = Wednesdaynext Tuesday = Wednesday, ... preserving (and reflecting) the order of the identifiers in the list. I know I can do this by hand, but I was wondering if datatype declarations are even possible within functions. If this isn't possible in SML, what are some languages (preferably functional) that allow this?
Li Chen
- 5.4k
- 3
- 35
- 71