<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def install(pkg=None,
            pkgs=None,
            user=None,
            install_global=False,
            env=None):
    '''
    Install a cabal package.

    pkg
        A package name in format accepted by cabal-install. See:
        https://wiki.haskell.org/Cabal-Install

    pkgs
        A list of packages names in same format as ``pkg``

    user
        The user to run cabal install with

    install_global
        Install package globally instead of locally

    env
        Environment variables to set when invoking cabal. Uses the
        same ``env`` format as the :py:func:`cmd.run
        <salt.modules.cmdmod.run>` execution function

    CLI Example:

    .. code-block:: bash

        salt '*' cabal.install shellcheck
        salt '*' cabal.install shellcheck-0.3.5
    '''

    cmd = ['cabal install']

    if install_global:
        cmd.append('--global')

    if pkg:
        cmd.append('"{0}"'.format(pkg))
    elif pkgs:
        cmd.append('"{0}"'.format('" "'.join(pkgs)))

    result = __salt__['cmd.run_all'](' '.join(cmd), runas=user, env=env)

    if result['retcode'] != 0:
        raise CommandExecutionError(result['stderr'])

    return result