functional-style datatypes in Python
- by Danny Roberts
For anyone who's spent some time with sml, ocaml, haskell, etc. when you go back to using C, Python, Java, etc. you start to notice things you never knew were missing. I'm doing some stuff in Python and I realized what I really want is a functional-style datatype like (for example)
datatype phoneme = Vowel of string | Consonant of voice * place * manner
datatype voice = Voiced | Voiceless
datatype place = Labial | Dental | Retroflex | Palatal | Velar | Glottal
datatype manner = Stop | Affricate | Fricative | Nasal | Lateral
type syllable = phoneme list
Does anyone have a particular way that they like to simulate this in Python?