A type pattern represents a query over a type annotation. We use these to identify objects of interest in the users code, namely:
Definitions with Debug.todo that we want to turn into code.
Definitions that provide functionality that generated code might want to hook into.
However, patterns can also be run in reverse, i.e. these can also be used to generate type annotations for auxiliary defintions.
The most important constructor here is Target, which denotes the type that will drive the code generation process.
Typed modulePath name arguments represents a type application, like Random.Generator target could be Typed ["Random"] "Generator" [ Target ].
Function represents a -> in a type. These are right-associative so a -> b -> c would be Function (GenericType "a") (Function (GenericType "b") (GenericType "c")).
GenericType takes a variable name. This name doesn't need to match the name of a type (so Typed [] "List" (GenericType "A")will matchList x), but do need to match each other. So Function (GenericType "a") (GenericType "a") will match x -> x but will not match x -> y.
A type pattern represents a query over a type annotation. We use these to identify objects of interest in the users code, namely:
Debug.todothat we want to turn into code.However, patterns can also be run in reverse, i.e. these can also be used to generate type annotations for auxiliary defintions.
The most important constructor here is
Target, which denotes the type that will drive the code generation process.Typed modulePath name argumentsrepresents a type application, likeRandom.Generator targetcould beTyped ["Random"] "Generator" [ Target ].Functionrepresents a->in a type. These are right-associative soa -> b -> cwould beFunction (GenericType "a") (Function (GenericType "b") (GenericType "c")).GenericTypetakes a variable name. This name doesn't need to match the name of a type (soTyped [] "List" (GenericType "A")will matchList x), but do need to match each other. SoFunction (GenericType "a") (GenericType "a")will matchx -> xbut will not matchx -> y.