4 ms·
I don't write C++, but in Haskell I always either list what I'm importing in the import declaration: import Data.Time.LocalTime (getZonedTime, localDay) o
by jolmg 8y ago
I don't write C++, but in Haskell I always either list what I'm importing in the import declaration:
import Data.Time.LocalTime (getZonedTime, localDay)
or I qualify it:
import qualified Data.Aeson as J
That way any uncommon identifier that's not defined in the same file is easy to identify where it came from. If I see `J.Value`, I know it came from `Data.Aeson`. If I see `localDay`, I know it came from `Data.Time.LocalTime`. Yes, the compiler is smart enough, but I don't care so much about it as I do to the humans that read the code, including myself.
> and why would any programmer use functions with the same name
Because they would otherwise be resorting to Hungarian notation.
For example, J.Value in my example above is for JSON values, but if I were to import:
import qualified Database.Esqueleto as E
E.Value would be for SQL values.
Similarly, `Data.List.empty` tells me if a list is empty, while `Data.Set.empty` tells me if a set is empty.