Created
November 18, 2020 15:04
-
-
Save supermacro/742eafee5242d6793b25135625d4bdd6 to your computer and use it in GitHub Desktop.
Thinking about tree structures in Elm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- A tree contains 2 kinds of nodes | |
-- at depths 1 through 2 you will have a node with a 'replies' field | |
-- at depth 3 the node is missing a 'replies' field | |
type alias TreeNode a = | |
{ a | |
| body : String | |
} | |
type alias WithReplies a = | |
{ replies : List a } | |
type CommentTree | |
= RootNode | |
(TreeNode (WithReplies | |
(TreeNode (WithReplies | |
(TreeNode {}))) | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment