Skip to content
Better HN
Top
Best
Ask
Show
New
Jobs
Search
⌘K
0 points
titzer
9y ago
0 comments
Save
Share
Use an enum.
0 comments
1 comments · 1 top-level
top
newest
oldest
eru
9y ago
No need to stop there. Not only use an enum, but also make it bear different types of values for different cases, and you arrive at Algebraic Datatypes. Eg, for trees you can have:
data Tree = Empty | Leaf Int | Node Tree Tree
j
/
k
navigate · click thread line to collapse