#![warn(missing_docs)]
use bhc_index::define_index;
use bhc_intern::{Ident, Symbol};
use bhc_span::Span;
define_index! {
pub struct ExprId;
pub struct PatId;
pub struct TypeId;
pub struct DeclId;
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum DocKind {
Preceding,
Trailing,
}
#[derive(Clone, Debug)]
pub struct DocComment {
pub text: String,
pub kind: DocKind,
pub span: Span,
}
impl DocComment {
#[must_use]
pub fn preceding(text: String, span: Span) -> Self {
Self {
text,
kind: DocKind::Preceding,
span,
}
}
#[must_use]
pub fn trailing(text: String, span: Span) -> Self {
Self {
text,
kind: DocKind::Trailing,
span,
}
}
}
#[derive(Clone, Debug)]
pub struct Module {
pub doc: Option<DocComment>,
pub pragmas: Vec<Pragma>,
pub name: Option<ModuleName>,
pub exports: Option<Vec<Export>>,
pub imports: Vec<ImportDecl>,
pub decls: Vec<Decl>,
pub span: Span,
}
#[derive(Clone, Debug)]
pub struct Pragma {
pub kind: PragmaKind,
pub span: Span,
}
#[derive(Clone, Debug)]
pub enum PragmaKind {
Language(Vec<Symbol>),
OptionsGhc(String),
Inline(Ident),
NoInline(Ident),
Inlinable(Ident),
Specialize(Ident, Type),
Unpack,
NoUnpack,
Source,
Complete(Vec<Ident>),
Minimal(String),
Deprecated(Option<Vec<Ident>>, String),
Warning(Option<Vec<Ident>>, String),
Other(String),
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum Extension {
GADTs,
TypeFamilies,
DataKinds,
KindSignatures,
RankNTypes,
ExistentialQuantification,
ScopedTypeVariables,
TypeApplications,
FlexibleInstances,
FlexibleContexts,
MultiParamTypeClasses,
FunctionalDependencies,
UndecidableInstances,
OverlappingInstances,
ConstraintKinds,
LambdaCase,
MultiWayIf,
BlockArguments,
PatternGuards,
ViewPatterns,
PatternSynonyms,
RecordWildCards,
NamedFieldPuns,
OverloadedStrings,
TupleSections,
OverloadedLists,
NumericUnderscores,
HexFloatLiterals,
BinaryLiterals,
NegativeLiterals,
BangPatterns,
StrictData,
Strict,
DeriveFunctor,
DeriveFoldable,
DeriveTraversable,
DeriveGeneric,
DeriveDataTypeable,
DeriveLift,
DerivingVia,
DerivingStrategies,
GeneralizedNewtypeDeriving,
StandaloneDeriving,
ForeignFunctionInterface,
CApiFFI,
UnliftedFFITypes,
TemplateHaskell,
TemplateHaskellQuotes,
QuasiQuotes,
TypeOperators,
ExplicitForAll,
ExplicitNamespaces,
EmptyDataDecls,
EmptyCase,
InstanceSigs,
DefaultSignatures,
NamedDefaults,
CPP,
Unknown(Symbol),
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum ExtensionStatus {
Supported,
Unimplemented,
Unknown,
}
impl Extension {
#[must_use]
pub fn status(&self) -> ExtensionStatus {
match self {
Self::GADTs
| Self::TypeFamilies
| Self::DataKinds
| Self::KindSignatures
| Self::ScopedTypeVariables
| Self::TypeApplications
| Self::FlexibleInstances
| Self::FlexibleContexts
| Self::MultiParamTypeClasses
| Self::FunctionalDependencies
| Self::TypeOperators
| Self::ExplicitForAll => ExtensionStatus::Supported,
Self::LambdaCase
| Self::MultiWayIf
| Self::BlockArguments
| Self::PatternGuards
| Self::ViewPatterns
| Self::PatternSynonyms
| Self::RecordWildCards
| Self::NamedFieldPuns
| Self::OverloadedStrings
| Self::TupleSections
| Self::OverloadedLists
| Self::NumericUnderscores
| Self::BinaryLiterals
| Self::NegativeLiterals => ExtensionStatus::Supported,
Self::BangPatterns | Self::StrictData | Self::Strict => ExtensionStatus::Supported,
Self::DeriveFunctor
| Self::DeriveFoldable
| Self::DeriveTraversable
| Self::DeriveGeneric
| Self::DerivingVia
| Self::DerivingStrategies
| Self::GeneralizedNewtypeDeriving
| Self::StandaloneDeriving
| Self::DeriveDataTypeable => ExtensionStatus::Supported,
Self::ForeignFunctionInterface => ExtensionStatus::Supported,
Self::EmptyDataDecls
| Self::EmptyCase
| Self::InstanceSigs
| Self::DefaultSignatures
| Self::ExplicitNamespaces
| Self::CPP => ExtensionStatus::Supported,
Self::UndecidableInstances | Self::OverlappingInstances => ExtensionStatus::Supported,
Self::ExistentialQuantification => ExtensionStatus::Supported,
Self::RankNTypes => ExtensionStatus::Supported,
Self::ConstraintKinds
| Self::HexFloatLiterals
| Self::DeriveLift
| Self::CApiFFI
| Self::UnliftedFFITypes
| Self::TemplateHaskell
| Self::TemplateHaskellQuotes
| Self::QuasiQuotes
| Self::NamedDefaults => ExtensionStatus::Unimplemented,
Self::Unknown(name) => {
match name.as_str() {
"Arrows"
| "MonoLocalBinds"
| "ImpredicativeTypes"
| "TypeFamilyDependencies"
| "DeriveAnyClass"
| "RoleAnnotations"
| "AllowAmbiguousTypes"
| "TypeSynonymInstances"
| "PackageImports"
| "NoImplicitPrelude"
| "NoMonomorphismRestriction"
| "DisambiguateRecordFields"
| "DuplicateRecordFields"
| "ApplicativeDo"
| "NumDecimals"
| "MagicHash"
| "UnboxedTuples"
| "TypeInType"
| "PolyKinds"
| "StarIsType"
| "ImportQualifiedPost"
| "StandaloneKindSignatures"
| "QuantifiedConstraints"
| "LinearTypes"
| "UnicodeSyntax"
| "ParallelListComp"
| "TransformListComp"
| "MonadComprehensions"
| "ExtendedDefaultRules"
| "PostfixOperators"
| "ScopedTypeVariables"
| "NoFieldSelectors" => ExtensionStatus::Supported,
_ => ExtensionStatus::Unknown,
}
}
}
}
#[must_use]
pub fn from_name(name: &str) -> Self {
match name {
"GADTs" => Self::GADTs,
"TypeFamilies" => Self::TypeFamilies,
"DataKinds" => Self::DataKinds,
"KindSignatures" => Self::KindSignatures,
"RankNTypes" | "Rank2Types" | "PolymorphicComponents" => Self::RankNTypes,
"ExistentialQuantification" => Self::ExistentialQuantification,
"ScopedTypeVariables" => Self::ScopedTypeVariables,
"TypeApplications" => Self::TypeApplications,
"FlexibleInstances" => Self::FlexibleInstances,
"FlexibleContexts" => Self::FlexibleContexts,
"MultiParamTypeClasses" => Self::MultiParamTypeClasses,
"FunctionalDependencies" => Self::FunctionalDependencies,
"UndecidableInstances" => Self::UndecidableInstances,
"OverlappingInstances" | "IncoherentInstances" => Self::OverlappingInstances,
"ConstraintKinds" => Self::ConstraintKinds,
"LambdaCase" => Self::LambdaCase,
"MultiWayIf" => Self::MultiWayIf,
"BlockArguments" => Self::BlockArguments,
"PatternGuards" => Self::PatternGuards,
"ViewPatterns" => Self::ViewPatterns,
"PatternSynonyms" => Self::PatternSynonyms,
"RecordWildCards" => Self::RecordWildCards,
"NamedFieldPuns" => Self::NamedFieldPuns,
"OverloadedStrings" => Self::OverloadedStrings,
"TupleSections" => Self::TupleSections,
"OverloadedLists" => Self::OverloadedLists,
"NumericUnderscores" => Self::NumericUnderscores,
"HexFloatLiterals" => Self::HexFloatLiterals,
"BinaryLiterals" => Self::BinaryLiterals,
"NegativeLiterals" => Self::NegativeLiterals,
"BangPatterns" => Self::BangPatterns,
"StrictData" => Self::StrictData,
"Strict" => Self::Strict,
"DeriveFunctor" => Self::DeriveFunctor,
"DeriveFoldable" => Self::DeriveFoldable,
"DeriveTraversable" => Self::DeriveTraversable,
"DeriveGeneric" => Self::DeriveGeneric,
"DeriveDataTypeable" => Self::DeriveDataTypeable,
"DeriveLift" => Self::DeriveLift,
"DerivingVia" => Self::DerivingVia,
"DerivingStrategies" => Self::DerivingStrategies,
"GeneralizedNewtypeDeriving" | "GeneralisedNewtypeDeriving" => {
Self::GeneralizedNewtypeDeriving
}
"StandaloneDeriving" => Self::StandaloneDeriving,
"ForeignFunctionInterface" | "FFI" => Self::ForeignFunctionInterface,
"CApiFFI" => Self::CApiFFI,
"UnliftedFFITypes" => Self::UnliftedFFITypes,
"TemplateHaskell" => Self::TemplateHaskell,
"TemplateHaskellQuotes" => Self::TemplateHaskellQuotes,
"QuasiQuotes" => Self::QuasiQuotes,
"TypeOperators" => Self::TypeOperators,
"ExplicitForAll" => Self::ExplicitForAll,
"ExplicitNamespaces" => Self::ExplicitNamespaces,
"EmptyDataDecls" => Self::EmptyDataDecls,
"EmptyCase" => Self::EmptyCase,
"InstanceSigs" => Self::InstanceSigs,
"DefaultSignatures" => Self::DefaultSignatures,
"NamedDefaults" => Self::NamedDefaults,
"CPP" => Self::CPP,
_ => Self::Unknown(Symbol::intern(name)),
}
}
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct ModuleName {
pub parts: Vec<Symbol>,
pub span: Span,
}
impl std::fmt::Display for ModuleName {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let joined = self
.parts
.iter()
.map(|s| s.as_str())
.collect::<Vec<_>>()
.join(".");
f.write_str(&joined)
}
}
#[derive(Clone, Debug)]
pub enum Export {
Var(Ident, Span),
Type(Ident, Option<Vec<Ident>>, Span),
Module(ModuleName, Span),
Pattern(Ident, Span),
}
#[derive(Clone, Debug)]
pub struct ImportDecl {
pub module: ModuleName,
pub qualified: bool,
pub alias: Option<ModuleName>,
pub spec: Option<ImportSpec>,
pub span: Span,
}
#[derive(Clone, Debug)]
pub enum ImportSpec {
Only(Vec<Import>),
Hiding(Vec<Import>),
}
#[derive(Clone, Debug)]
pub enum Import {
Var(Ident, Span),
Type(Ident, Option<Vec<Ident>>, Span),
Pattern(Ident, Span),
}
#[derive(Clone, Debug)]
pub enum Decl {
TypeSig(TypeSig),
FunBind(FunBind),
DataDecl(DataDecl),
TypeAlias(TypeAlias),
Newtype(NewtypeDecl),
ClassDecl(ClassDecl),
InstanceDecl(InstanceDecl),
Foreign(ForeignDecl),
Fixity(FixityDecl),
PragmaDecl(Pragma),
StandaloneDeriving(StandaloneDeriving),
PatternSynonym(PatternSynonymDecl),
TypeFamilyDecl(TypeFamilyDecl),
TypeInstanceDecl(TypeInstanceDecl),
DataFamilyDecl(DataFamilyDecl),
DataInstanceDecl(DataInstanceDecl),
}
#[derive(Clone, Debug)]
pub struct StandaloneDeriving {
pub class: Ident,
pub ty: Type,
pub span: Span,
}
#[derive(Clone, Debug)]
pub struct PatternSynonymDecl {
pub name: Ident,
pub args: Vec<Ident>,
pub direction: PatSynDir,
pub pattern: Pat,
pub span: Span,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum TypeFamilyKind {
Open,
Closed,
}
#[derive(Clone, Debug)]
pub struct TypeFamilyDecl {
pub doc: Option<DocComment>,
pub name: Ident,
pub params: Vec<TyVar>,
pub kind: Option<Kind>,
pub family_kind: TypeFamilyKind,
pub equations: Vec<TypeFamilyEqn>,
pub span: Span,
}
#[derive(Clone, Debug)]
pub struct TypeFamilyEqn {
pub args: Vec<Type>,
pub rhs: Type,
pub span: Span,
}
#[derive(Clone, Debug)]
pub struct TypeInstanceDecl {
pub doc: Option<DocComment>,
pub name: Ident,
pub args: Vec<Type>,
pub rhs: Type,
pub span: Span,
}
#[derive(Clone, Debug)]
pub struct DataFamilyDecl {
pub doc: Option<DocComment>,
pub name: Ident,
pub params: Vec<TyVar>,
pub kind: Option<Kind>,
pub span: Span,
}
#[derive(Clone, Debug)]
pub struct DataInstanceDecl {
pub doc: Option<DocComment>,
pub family_name: Ident,
pub args: Vec<Type>,
pub constrs: Vec<ConDecl>,
pub gadt_constrs: Vec<GadtConDecl>,
pub deriving: Vec<DerivingClause>,
pub span: Span,
}
#[derive(Clone, Debug)]
pub enum PatSynDir {
Bidirectional,
Unidirectional,
}
#[derive(Clone, Debug)]
pub struct TypeSig {
pub doc: Option<DocComment>,
pub names: Vec<Ident>,
pub ty: Type,
pub span: Span,
}
#[derive(Clone, Debug)]
pub struct FunBind {
pub doc: Option<DocComment>,
pub name: Ident,
pub clauses: Vec<Clause>,
pub span: Span,
}
#[derive(Clone, Debug)]
pub struct Clause {
pub pats: Vec<Pat>,
pub rhs: Rhs,
pub wheres: Vec<Decl>,
pub span: Span,
}
#[derive(Clone, Debug)]
pub enum Rhs {
Simple(Expr, Span),
Guarded(Vec<GuardedRhs>, Span),
}
#[derive(Clone, Debug)]
pub struct GuardedRhs {
pub guards: Vec<Guard>,
pub body: Expr,
pub span: Span,
}
#[derive(Clone, Debug)]
pub enum Guard {
Pattern(Pat, Expr, Span),
Expr(Expr, Span),
}
impl Guard {
#[must_use]
pub fn span(&self) -> Span {
match self {
Self::Pattern(_, _, s) | Self::Expr(_, s) => *s,
}
}
}
#[derive(Clone, Debug)]
pub enum DerivingStrategy {
Default,
Stock,
Newtype,
Anyclass,
Via(Type),
}
#[derive(Clone, Debug)]
pub struct DerivingClause {
pub strategy: DerivingStrategy,
pub class: Ident,
}
#[derive(Clone, Debug)]
pub struct DataDecl {
pub doc: Option<DocComment>,
pub name: Ident,
pub params: Vec<TyVar>,
pub constrs: Vec<ConDecl>,
pub gadt_constrs: Vec<GadtConDecl>,
pub deriving: Vec<DerivingClause>,
pub span: Span,
}
#[derive(Clone, Debug)]
pub struct GadtConDecl {
pub doc: Option<DocComment>,
pub name: Ident,
pub ty: Type,
pub span: Span,
}
#[derive(Clone, Debug)]
pub struct ConDecl {
pub doc: Option<DocComment>,
pub name: Ident,
pub fields: ConFields,
pub existential_vars: Vec<TyVar>,
pub existential_context: Vec<Constraint>,
pub span: Span,
}
#[derive(Clone, Debug)]
pub enum ConFields {
Positional(Vec<Type>),
Record(Vec<FieldDecl>),
}
#[derive(Clone, Debug)]
pub struct FieldDecl {
pub doc: Option<DocComment>,
pub name: Ident,
pub ty: Type,
pub span: Span,
}
#[derive(Clone, Debug)]
pub struct TypeAlias {
pub doc: Option<DocComment>,
pub name: Ident,
pub params: Vec<TyVar>,
pub ty: Type,
pub span: Span,
}
#[derive(Clone, Debug)]
pub struct NewtypeDecl {
pub doc: Option<DocComment>,
pub name: Ident,
pub params: Vec<TyVar>,
pub constr: ConDecl,
pub deriving: Vec<DerivingClause>,
pub span: Span,
}
#[derive(Clone, Debug)]
pub struct ClassDecl {
pub doc: Option<DocComment>,
pub context: Vec<Constraint>,
pub name: Ident,
pub params: Vec<TyVar>,
pub fundeps: Vec<FunDep>,
pub assoc_types: Vec<AssocType>,
pub methods: Vec<Decl>,
pub span: Span,
}
#[derive(Clone, Debug)]
pub struct AssocType {
pub name: Ident,
pub params: Vec<TyVar>,
pub kind: Option<Kind>,
pub default: Option<Type>,
pub span: Span,
}
#[derive(Clone, Debug)]
pub enum Kind {
Star,
Arrow(Box<Kind>, Box<Kind>),
Var(Ident),
}
#[derive(Clone, Debug)]
pub struct FunDep {
pub from: Vec<Ident>,
pub to: Vec<Ident>,
pub span: Span,
}
#[derive(Clone, Debug)]
pub struct InstanceDecl {
pub doc: Option<DocComment>,
pub context: Vec<Constraint>,
pub class: Ident,
pub ty: Type,
pub assoc_type_defs: Vec<AssocTypeDef>,
pub methods: Vec<Decl>,
pub span: Span,
}
#[derive(Clone, Debug)]
pub struct AssocTypeDef {
pub name: Ident,
pub args: Vec<Type>,
pub rhs: Type,
pub span: Span,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum ForeignSafety {
Safe,
Unsafe,
Interruptible,
}
#[derive(Clone, Debug)]
pub struct ForeignDecl {
pub doc: Option<DocComment>,
pub kind: ForeignKind,
pub convention: Symbol,
pub safety: ForeignSafety,
pub external_name: Option<String>,
pub name: Ident,
pub ty: Type,
pub span: Span,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum ForeignKind {
Import,
Export,
}
#[derive(Clone, Debug)]
pub struct FixityDecl {
pub fixity: Fixity,
pub prec: u8,
pub ops: Vec<Ident>,
pub span: Span,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Fixity {
Left,
Right,
None,
}
#[derive(Clone, Debug)]
pub enum Expr {
Var(Ident, Span),
QualVar(ModuleName, Ident, Span),
Con(Ident, Span),
QualCon(ModuleName, Ident, Span),
Lit(Lit, Span),
App(Box<Expr>, Box<Expr>, Span),
Lam(Vec<Pat>, Box<Expr>, Span),
Let(Vec<Decl>, Box<Expr>, Span),
If(Box<Expr>, Box<Expr>, Box<Expr>, Span),
Case(Box<Expr>, Vec<Alt>, Span),
Do(Vec<Stmt>, Span),
Tuple(Vec<Expr>, Span),
List(Vec<Expr>, Span),
ArithSeq(ArithSeq, Span),
ListComp(Box<Expr>, Vec<Stmt>, Span),
RecordCon(Ident, Vec<FieldBind>, bool, Span),
QualRecordCon(ModuleName, Ident, Vec<FieldBind>, bool, Span),
RecordUpd(Box<Expr>, Vec<FieldBind>, Span),
Infix(Box<Expr>, Ident, Box<Expr>, Span),
Neg(Box<Expr>, Span),
Paren(Box<Expr>, Span),
Ann(Box<Expr>, Type, Span),
TypeApp(Box<Expr>, Type, Span),
Lazy(Box<Expr>, Span),
Wildcard(Span),
}
impl Expr {
#[must_use]
pub fn span(&self) -> Span {
match self {
Self::Var(_, s)
| Self::QualVar(_, _, s)
| Self::Con(_, s)
| Self::QualCon(_, _, s)
| Self::Lit(_, s)
| Self::App(_, _, s)
| Self::Lam(_, _, s)
| Self::Let(_, _, s)
| Self::If(_, _, _, s)
| Self::Case(_, _, s)
| Self::Do(_, s)
| Self::Tuple(_, s)
| Self::List(_, s)
| Self::ArithSeq(_, s)
| Self::ListComp(_, _, s)
| Self::RecordCon(_, _, _, s)
| Self::QualRecordCon(_, _, _, _, s)
| Self::RecordUpd(_, _, s)
| Self::Infix(_, _, _, s)
| Self::Neg(_, s)
| Self::Paren(_, s)
| Self::Ann(_, _, s)
| Self::TypeApp(_, _, s)
| Self::Lazy(_, s)
| Self::Wildcard(s) => *s,
}
}
}
#[derive(Clone, Debug, PartialEq)]
pub enum Lit {
Int(i64),
Float(f64),
Char(char),
String(String),
}
#[derive(Clone, Debug)]
pub enum ArithSeq {
From(Box<Expr>),
FromThen(Box<Expr>, Box<Expr>),
FromTo(Box<Expr>, Box<Expr>),
FromThenTo(Box<Expr>, Box<Expr>, Box<Expr>),
}
#[derive(Clone, Debug)]
pub struct Alt {
pub pat: Pat,
pub rhs: Rhs,
pub wheres: Vec<Decl>,
pub span: Span,
}
#[derive(Clone, Debug)]
pub enum Stmt {
Generator(Pat, Expr, Span),
Qualifier(Expr, Span),
LetStmt(Vec<Decl>, Span),
}
#[derive(Clone, Debug)]
pub struct FieldBind {
pub qualifier: Option<ModuleName>,
pub name: Ident,
pub value: Option<Expr>,
pub span: Span,
}
#[derive(Clone, Debug)]
pub enum Pat {
Wildcard(Span),
Var(Ident, Span),
Lit(Lit, Span),
Con(Ident, Vec<Pat>, Span),
QualCon(ModuleName, Ident, Vec<Pat>, Span),
Infix(Box<Pat>, Ident, Box<Pat>, Span),
Tuple(Vec<Pat>, Span),
List(Vec<Pat>, Span),
Record(Ident, Vec<FieldPat>, bool, Span),
QualRecord(ModuleName, Ident, Vec<FieldPat>, bool, Span),
As(Ident, Box<Pat>, Span),
Lazy(Box<Pat>, Span),
Bang(Box<Pat>, Span),
Paren(Box<Pat>, Span),
Ann(Box<Pat>, Type, Span),
View(Box<Expr>, Box<Pat>, Span),
}
impl Pat {
#[must_use]
pub fn span(&self) -> Span {
match self {
Self::Wildcard(s)
| Self::Var(_, s)
| Self::Lit(_, s)
| Self::Con(_, _, s)
| Self::QualCon(_, _, _, s)
| Self::Infix(_, _, _, s)
| Self::Tuple(_, s)
| Self::List(_, s)
| Self::Record(_, _, _, s)
| Self::QualRecord(_, _, _, _, s)
| Self::As(_, _, s)
| Self::Lazy(_, s)
| Self::Bang(_, s)
| Self::Paren(_, s)
| Self::Ann(_, _, s)
| Self::View(_, _, s) => *s,
}
}
}
#[derive(Clone, Debug)]
pub struct FieldPat {
pub qualifier: Option<ModuleName>,
pub name: Ident,
pub pat: Option<Pat>,
pub span: Span,
}
#[derive(Clone, Debug)]
pub enum Type {
Var(TyVar, Span),
Con(Ident, Span),
QualCon(ModuleName, Ident, Span),
App(Box<Type>, Box<Type>, Span),
Fun(Box<Type>, Box<Type>, Span),
Tuple(Vec<Type>, Span),
List(Box<Type>, Span),
Paren(Box<Type>, Span),
Forall(Vec<TyVar>, Box<Type>, Span),
Constrained(Vec<Constraint>, Box<Type>, Span),
PromotedList(Vec<Type>, Span),
NatLit(u64, Span),
Bang(Box<Type>, Span),
Lazy(Box<Type>, Span),
InfixOp(Box<Type>, Ident, Box<Type>, Span),
}
impl Type {
#[must_use]
pub fn span(&self) -> Span {
match self {
Self::Var(_, s)
| Self::Con(_, s)
| Self::QualCon(_, _, s)
| Self::App(_, _, s)
| Self::Fun(_, _, s)
| Self::Tuple(_, s)
| Self::List(_, s)
| Self::Paren(_, s)
| Self::Forall(_, _, s)
| Self::Constrained(_, _, s)
| Self::PromotedList(_, s)
| Self::NatLit(_, s)
| Self::Bang(_, s)
| Self::Lazy(_, s)
| Self::InfixOp(_, _, _, s) => *s,
}
}
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct TyVar {
pub name: Ident,
pub span: Span,
}
#[derive(Clone, Debug)]
pub struct Constraint {
pub class: Ident,
pub args: Vec<Type>,
pub span: Span,
}