Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- type PType = Type TyName DefaultUni SrcSpan
- varType ∷ Parser PType
- funType ∷ Parser PType
- allType ∷ Parser PType
- lamType ∷ Parser PType
- ifixType ∷ Parser PType
- builtinType ∷ Parser PType
- sopType ∷ Parser PType
- appType ∷ Parser PType
- kind ∷ Parser (Kind SrcSpan)
- pType ∷ Parser PType
- defaultUniApplication ∷ Parser (SomeTypeIn (Kinded DefaultUni))
- defaultUni ∷ Parser (SomeTypeIn (Kinded DefaultUni))
- tyName ∷ Parser TyName
Documentation
type PType = Type TyName DefaultUni SrcSpan Source #
A PLC Type
to be parsed. ATM the parser only works
for types in the DefaultUni
with DefaultFun
.
defaultUniApplication ∷ Parser (SomeTypeIn (Kinded DefaultUni)) Source #
Parser for built-in type applications. The textual names here should match the ones in the PrettyBy instance for DefaultUni in PlutusCore.Default.Universe.
defaultUni ∷ Parser (SomeTypeIn (Kinded DefaultUni)) Source #
Parser for built-in types (the ones from DefaultUni
specifically).
Kinded
is needed for checking that a type function can be applied to its argument.
I.e. we do Plutus kind checking of builtin type applications during parsing, which is
unfortunate, but there's no way we could construct a DefaultUni
otherwise.
In case of kind error no sensible message is shown, only an overly general one:
>>>
:set -XTypeApplications
>>>
:set -XOverloadedStrings
>>>
import PlutusCore.Error
>>>
import PlutusCore.Quote
>>>
let runP = putStrLn . either display display . runQuoteT . parseGen @ParserErrorBundle defaultUni
>>>
runP "(list integer)"
(list integer)>>>
runP "(bool integer)"
test:1:14: | 1 | (bool integer) | ^ expecting "bool", "bytestring", "data", "integer", "list", "pair", "string", "unit", or '('
This is to be fixed.
One thing we could do to avoid doing kind checking during parsing is to parse into
data TextualUni a where TextualUni :: TextualUni (Esc (Tree Text))
i.e. parse into Tree Text
and do the kind checking afterwards, but given that we'll still need
to do the kind checking of builtins regardless (even for UPLC), we don't win much by deferring
doing it.