use chumsky::{primitive::just, Parser};

use crate::{
    __internal__parser,
    ast::TypeDefinition,
    parse::{
        source_file::{ident, source_file_whitespace_or_comments, ty::ty},
        with_span,
    },
};

__internal__parser! {pub type_definition, TypeDefinition<'s>, {
    just("type")
        .then(source_file_whitespace_or_comments().at_least(1))
        .ignore_then(with_span(ident()))
        .then_ignore(just("=").padded_by(source_file_whitespace_or_comments()))
        .then(with_span(ty()))
        .then_ignore(source_file_whitespace_or_comments().then(just(';')))
        .map(|(name, ty)| TypeDefinition{name, ty})
}}
