def hsinspect(module = None, file = None, cabal = None, ghc_opts = []):
    cmd = ['hsinspect']
    on_result = lambda s: s
    if module:
        cmd.extend([module])
        on_result = parse_module
    elif file:
        cmd.extend([file])
        on_result = parse_module
    elif cabal:
        cmd.extend([cabal])
    else:
        log('hsinspect must specify module, file or cabal', log_debug)
        return None

    for opt in ghc_opts:
        cmd.extend(['-g', opt])

    r = call_and_wait_tool(cmd, 'hsinspect', lambda s: json.loads(s), file, None)
    if r:
        if 'error' in r:
            log('hsinspect returns error: {0}'.format(r['error']), log_error)
        else:
            return on_result(r)
    return None
dataset/ETHPy150Open SublimeHaskell/SublimeHaskell/hsdev.py/hsinspect/original