pub fn constr_col(collection: &AST, constr: &mut ConstrBuilder) -> TypeResult<ConstrBuilder> {
    let col = match &collection.node {
        Node::Set { elements } | Node::List { elements } | Node::Tuple { elements } =>
            if let Some(first) = elements.first() {
                for element in elements {
                    constr.add(
                        "collection",
                        &Expected::try_from(element)?,
                        &Expected::try_from(first)?
                    )
                }
                Expect::Collection {
                    ty: Box::from(Expected::new(&first.pos, &Expression { ast: first.clone() }))
                }
            } else {
                Expect::Collection { ty: Box::from(Expected::new(&collection.pos, &ExpressionAny)) }
            },

        _ => Expect::Collection { ty: Box::from(Expected::new(&collection.pos, &ExpressionAny)) }
    };

    let col_exp = Expected::new(&collection.pos, &col);
    constr.add("collection", &col_exp, &Expected::try_from(collection)?);
    Ok(constr.clone())
}
/// Generate constraint for collection by taking first element
///
/// The assumption here being that every element in the set has the same type.
Generate constraint for collection by taking first element
The assumption here being that every element in the set has the same type.
Generate constraint for collection by taking first element The assumption here being that every element in the set has the same type .
pub fn constr_col(collection: &AST, constr: &mut ConstrBuilder) -> TypeResult<ConstrBuilder> {
    let col = match &collection.node {
        Node::Set { elements } | Node::List { elements } | Node::Tuple { elements } =>
            if let Some(first) = elements.first() {
                for element in elements {
                    constr.add(
                        "collection",
                        &Expected::try_from(element)?,
                        &Expected::try_from(first)?
                    )
                }
                Expect::Collection {
                    ty: Box::from(Expected::new(&first.pos, &Expression { ast: first.clone() }))
                }
            } else {
                Expect::Collection { ty: Box::from(Expected::new(&collection.pos, &ExpressionAny)) }
            },
        _ => Expect::Collection { ty: Box::from(Expected::new(&collection.pos, &ExpressionAny)) }
    };
    let col_exp = Expected::new(&collection.pos, &col);
    constr.add("collection", &col_exp, &Expected::try_from(collection)?);
    Ok(constr.clone())
}
pub fn constr_col ( collection : & AST , constr : & mut ConstrBuilder ) -> TypeResult < ConstrBuilder > { let col = match & collection . node { Node :: Set { elements } | Node :: List { elements } | Node :: Tuple { elements } => if let Some ( first ) = elements . first ( ) { for element in elements { constr . add ( " " , & Expected :: try_from ( element ) ? , & Expected :: try_from ( first ) ? ) } Expect :: Collection { ty : Box :: from ( Expected :: new ( & first . pos , & Expression { ast : first . clone ( ) } ) ) } } else { Expect :: Collection { ty : Box :: from ( Expected :: new ( & collection . pos , & ExpressionAny ) ) } } , _ => Expect :: Collection { ty : Box :: from ( Expected :: new ( & collection . pos , & ExpressionAny ) ) } } ; let col_exp = Expected :: new ( & collection . pos , & col ) ; constr . add ( " " , & col_exp , & Expected :: try_from ( collection ) ? ) ; Ok ( constr . clone ( ) ) }
Generate constraint for collection by taking first element
The assumption here being that every element in the set has the same type.
Generate constraint for collection by taking first element The assumption here being that every element in the set has the same type .
collection
&AST
constr
&mut ConstrBuilder