pyret-lang
pyret-lang copied to clipboard
Aliasing an unparamaterized built-in type produces an error in the REPL
It would seem that aliasing built-in types (with the type-stmt type) leads to an error message in the REPL — but only if the aliased type is not parameterized. One workaround is to just… parameterize your non-parametric builtin types?
# Aliasing a parameterized type is OK
type NumList = List<Number>
# but aliasing unparameterized is not:
type ListAlias = List # <- comment out to use REPL!
# and the same goes for non-parametric builtins:
type NumAlias = Number # <- comment out to use REPL!
# …unless you add a parameter anyways
type OKNumAlias = Number<String>
# Aliasing user-defined types, however, seems to be OK
data Foo:
| foo()
end
type Bar = Foo
# Note that this computation always prints in the REPL:
1 + 1
# but attempting to interact with the repl throws the following error:
# "Could not find type NumAlias on module definitions://"
Note that running this with the type checker does not produce the error in the REPL. (Then NumAlias works, but you can't create anything of type OKNumAlias — not that you need it in that scenario.)