plutus-core-1.39.0.0: Language library for Plutus Core
Safe HaskellSafe-Inferred
LanguageHaskell2010

PlutusCore.Parser.Type

Synopsis

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.

pTypeParser PType Source #

Parser for PType.

defaultUniApplicationParser (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.

defaultUniParser (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.