#ifndef GOOSE_BUILTINS_TYPES_PARAM_H
#define GOOSE_BUILTINS_TYPES_PARAM_H
namespace goose::builtins
{
template< typename T, typename V >
auto ParamPat( T&& type, V&& val )
{
// If the type is a tuple of type, convert it to the type of a tuple.
// (the type of a tuple is just a list of values, so just extract the value part of the tuple)
if( auto typeVal = ValueFromIRExpr( type ); typeVal && IsTuple( *typeVal ) )
return ValueToIRExpr( Value( ValueToIRExpr( TupleOfTypesToTupleType( *typeVal ) ), HOLE( "_"_sid ) ) );
return ValueToIRExpr( Value( forward< T >( type ), forward< V >( val ) ) );
}
template< typename T >
auto ParamPat( T&& type )
{
// If the type is a tuple of type, convert it to the type of a tuple.
// (the type of a tuple is just a list of values, so just extract the value part of the tuple)
if( auto typeVal = ValueFromIRExpr( type ); typeVal && IsTuple( *typeVal ) )
return ValueToIRExpr( ValuePattern( TSID( param ), ValueToIRExpr( TupleOfTypesToTupleType( *typeVal ) ), HOLE( "_"_sid ) ) );
return ValueToIRExpr( ValuePattern( TSID( param ), forward< T >( type ), HOLE( "_"_sid ) ) );
}
template< typename T >
auto ParamPatFromTerm( T&& t )
{
return forward< T >( t );
}
}
#endif