Skip to content

Is it possible to type a non-empty list? #3368

Discussion options

You must be logged in to vote

I added an Empty state to my Node type and that removed the need for a non-empty list. i.e.

pub type Node(a) {
  Node(data: a, next: Node(a))
  Empty
}

A non-empty list was not necessary in this case. I'm not sure if it would be useful in other cases or if it is just a skill issue 😅.

P.S. Yes, I'm aware the build-in list type is a singly-linked list. I'm doing this as a learning exercise.

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by daniel-nagy
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants