I want to make a parser that can handle a recursive data structure. E.g.
["a", ["b"]]
["a", ["b", ["c", "d"]]]
Here is my attempt https://ellie-app.com/7MdkFhPYmTDa1
The first example above should parse into AstList [AstVal "a", AstList [AstVal "b" ] ]
In listParser
I tried setting item = parser
, but the compiler complains with:
The `listParser` value depends on itself through the following chain of
definitions:
┌─────┐
│ listParser
│ ↓
│ parser
└─────┘
How can I make this parser recursive? Thanks