swarm-game / swarm

Resource gathering + programming game
Other
820 stars 51 forks source link

Parse and validate swarm types in descriptions #1406

Open xsebek opened 11 months ago

xsebek commented 11 months ago

In #1106, parsing types was left out, as they are not used that often. (Type ascription is just an expression.)

Parse and validate raw code snippets marked as types:

Swarm has a special type, `Unit`{=type}, with only one value

and include them in the markdown AST. Optionally make the Document a bifunctor/... on type type.

byorgey commented 11 months ago

Making Document a bifunctor does not really make sense to me. It seems like instead we should just use something like Document (Either Syntax Type), or better yet make a new type data Parsed = ParsedSyntax Syntax | ParsedType Type | ParsedEntity Entity | ... or something like that, and then use Document Parsed.

(I don't think I actually like the name Parsed, I just had to put something.)

xsebek commented 11 months ago

@byorgey thanks, that sounds like a better approach 👍

IIRC letting lens create a prism for it should allow me to s ^. sTerm . plate . _PSyntax . getConst in pedagogy. 🤔