-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
import Prelude by default #50
Comments
I'm testing the default import of prelude unqualified. There are many problems with list functions that doesn't work on ByteString. For instance: {-# LANGUAGE OverloadedStrings #-}
module Main where
import qualified Data.ByteString.Lazy.Char8 as C8
import Prelude
main :: IO ∅
main = do
let s = C8.pack "Foo bar"
let w = words s
print w doesn't compile:
and we have the same problem in
We should think really carefully what we want to import automatically because it can confuse the user. I don't think
|
Well, having map not work on lists isn't ideal either. Maybe this custom module could expose a two-parameter typeclass supporting both Personally, for the first release, I would just qualify ByteString with B and remind the user that all string functions must be qualified with B. We could also have T for Data.Text. What is least confusing for the user: that strings are instances of ByteString instead of String, or that prelude functions aren't available and/or don't have the types they do in the prelude? What is the least inconvenient, remembering to add the prefix I think the first answer to each question is slightly better, but I could easily be convinced otherwise. |
I agree with you. What do you think if we close this and open a new issue about the default |
This issue is about automatically importing the prelude if it does not appear in prelude.hs, just like the Prelude is implicitly available by default in a standard Haskell program unless you explicitly discard it or import it qualified. Whether the default contents of prelude.hs should import the Prelude or not (implicitly or explicitly) is indeed a different issue. Let's open a new one for choosing the default contents, but could we please leave this one open? I was very confused when my first attempt at creating a prelude.hs containing just "rev = reverse" failed to compile. |
That's because of the p.s. now that we have the source parser we probably can extract the extensions and set them in |
Letting the user decide if he wants NoImplicitPrelude? Good idea, I didn't think of that! Doing so in a more general way by accepting any extension and passing them along to hint? Absolutely brilliant! |
I let you close the issue. As side note I kept the |
If the user does not mention Prelude in ~/.hawk/prelude.hs, import it unqualified.
If the user imports the Prelude unqualified, import it unqualified.
If the user imports the Prelude qualified, import it with the same qualifier.
The text was updated successfully, but these errors were encountered: