What is TypeOpName and TypeArrName from purescript-cst?

from http://hackage.haskell.org/package/purescript-0.13.6/docs/Language-PureScript-CST-Types.html#t:Type

what is the meaning of

TypeOpName a (QualifiedName (OpName TypeOpName))

constructor

created in parser with

%token
  ...
  SYMBOL             { SourceToken _ (TokSymbolName [] _) }
  QUAL_SYMBOL        { SourceToken _ (TokSymbolName _ _) }

qualSymbol :: { QualifiedOpName }
  : SYMBOL {% qualifiedOpName <\$> toQualifiedName N.OpName $1 }
  | QUAL_SYMBOL {% qualifiedOpName <\$> toQualifiedName N.OpName $1 }
  | '(..)' {% qualifiedOpName <\$> toQualifiedName N.OpName $1 }

typeAtom :: { Type ()}
  ....
  | qualSymbol { TypeOpName () (getQualifiedOpName $1) }

for example this is (..) in foo :: Foo ((..) :: Type)

what is (..) and SYMBOL and QUAL_SYMBOL?


TypeArrName a SourceToken

constructor

created in parser with

typeAtom :: { Type ()}
  ....
  | '(->)' { TypeArrName () $1 }

for example this is (->) in foo :: Foo (->)

what is (->)?

Those are type operators. Contextual syntax needs to be called out specifically. (..) is syntax when importing constructors for a data type (Foo(..)), but it’s otherwise a valid operator identifier. -> is a reserved operator for function arrows, and so it requires some special support.

1 Like