Skip to content

Add an option to print out what is in the context #46

@melrief

Description

@melrief

The user should be able to query Hawk about the context of the user expressions.

For instance, if user's prelude.hs is:

{-# LANGUAGE OverloadedStrings #-}
import qualified Data.Bool as B
import Data.List (length)

l = length

then the user query should return:

> hawk -q
{-# LANGUAGE OverloadedStrings -#}
data B.Bool = B.False | B.True
B.&& :: Bool -> Bool -> Bool
B.not :: Bool -> Bool
B.otherwise :: Bool
B.|| :: Bool -> Bool -> Bool
l :: [a] -> Int
length :: [a] -> Int

the output of the query should be readable by the user and is useful to understand what is the context.
The output of -q can be very long and we should think about how to organize it. For example, we could put data structure before function declarations, or we can have different options to toggle language extensions, data structures, functions...:

> hawk -q functions
B.&& :: Bool -> Bool -> Bool
B.not :: Bool -> Bool
B.otherwise :: Bool
B.|| :: Bool -> Bool -> Bool
l :: [a] -> Int
length :: [a] -> Int

This is an improvement and can be very helpful when the user configuration grows.

A bonus of such an option is to use this system not only to show to the user the context but also to do a sanity check on ambiguities:

import Data.List (length)
import Prelude (length)
> hawk --sanity-check
length is ambiguous: it is imported by both Data.List and Prelude

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions