/// Synthesize the type of a literal.
Synthesize the type of a literal.
Synthesize the type of a literal .
pub fn synth(
    kind: LiteralKind,
    src: &SpannedString<'_>,
) -> Result<(LiteralIntro, Rc<domain::Type>), Diagnostic<FileSpan>> {
    use mltt_concrete::LiteralKind as LitKind;
    use mltt_core::literal::{LiteralIntro as LitIntro, LiteralType as LitType};
    match kind {
        LitKind::String => Ok((
            LitIntro::String(Rc::from(parse_string(src)?)),
            Rc::from(domain::Value::literal_ty(LitType::String)),
        )),
        LitKind::Char => Ok((
            LitIntro::Char(parse_char(src)?),
            Rc::from(domain::Value::literal_ty(LitType::Char)),
        )),
        LitKind::Int | LitKind::Float => Err(Diagnostic::new_error("ambiguous literal")
            .with_label(DiagnosticLabel::new_primary(src.span()))),
    }
}
pub fn synth ( kind : LiteralKind , src : & SpannedString < ' _ > , ) -> Result < ( LiteralIntro , Rc < domain :: Type > ) , Diagnostic < FileSpan > > { use mltt_concrete :: LiteralKind as LitKind ; use mltt_core :: literal :: { LiteralIntro as LitIntro , LiteralType as LitType } ; match kind { LitKind :: String => Ok ( ( LitIntro :: String ( Rc :: from ( parse_string ( src ) ? ) ) , Rc :: from ( domain :: Value :: literal_ty ( LitType :: String ) ) , ) ) , LitKind :: Char => Ok ( ( LitIntro :: Char ( parse_char ( src ) ? ) , Rc :: from ( domain :: Value :: literal_ty ( LitType :: Char ) ) , ) ) , LitKind :: Int | LitKind :: Float => Err ( Diagnostic :: new_error ( " " ) . with_label ( DiagnosticLabel :: new_primary ( src . span ( ) ) ) ) , } }
Synthesize the type of a literal.
Synthesize the type of a literal .
kind
LiteralKind
src
&SpannedString<'_>