<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def parse(el, typ):
 """ Parse a ``BeautifulSoup`` element as the given type. """

    if not el:
        return typ()
    txt = text(el)
    if not txt:
        return typ()
    return typ(txt)