Skip to content
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

move post-processing inside hint #40

Closed
gelisam opened this issue Aug 12, 2013 · 5 comments
Closed

move post-processing inside hint #40

gelisam opened this issue Aug 12, 2013 · 5 comments

Comments

@gelisam
Copy link
Collaborator

gelisam commented Aug 12, 2013

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.

@ghost ghost assigned gelisam Aug 14, 2013
@gelisam
Copy link
Collaborator Author

gelisam commented Aug 14, 2013

We can't have an unqualified Prelude yet, as it would conflict with ByteString's many existing bindings, such as map :: (Char -> Char) -> ByteString -> ByteString. And we can't make ByteString qualified either, because hint complains that ByteString is not in scope. I think this is due to the fact that we ask hint to evaluate a value of type ByteString -> IO (); that type must somehow get inserted unqualified into the expression to be evaluated.

@gelisam
Copy link
Collaborator Author

gelisam commented Aug 14, 2013

New branch, "qualify_bytestring", with a proof-of-concept in which I move all the post-processing inside hint so that we only ask it to evaluate values of type IO ().

What do you guys think, is this the way forward? Should I continue working on this branch to bring back the features I have temporarily removed, or should we try to fix hint instead?

@melrief
Copy link
Collaborator

melrief commented Aug 14, 2013

I think yours is a clever solution @gelisam. I used a similar solution when I had the problem with the output. When I started hsp, the expression to evaluate had type ByteString -> Rows a. hint wasn't able to recognise a, so I encapsulated the output writer (printRows and printRow) in the user expression and the type became ByteString -> IO (). Now you had a similar problem with the input, that was ByteString, and you encapsulate an input reader based on the options inside the user expression and the type became IO ().

I think we should stick with your solution, IO () for two reasons: i) there is no easy solution to the hint problem, even if we enforce the import of only the type ii) in this way, in future we could give to the user the possibility to change both the input reader and the output writer. For now we are working with lazy streams of ByteString but in future the user could have two options to specify that, for example, he prefers to work with Text or String instead of ByteString. The expression to evaluate will still have type IO (), so no changes to the hawk core, but it will work with different types:

> hawk --input-reader System.IO.getContents --output-writer System.IO.putStrLn "show . map (\w -> (head w,length w)) . group . sort . concatMap words . lines"

The example whould give you a vague idea of what I have in mind. Imagine if we give the possibility to the user to define:

  • its own input reader, that is the function that reads from stdin or file
  • its own output writers, like currently we have printRow or printRows

@gelisam
Copy link
Collaborator Author

gelisam commented Aug 16, 2013

For more clarity of discussion, this issue (#40) now refers to the sub-task in which I moved all the post-processing inside of hint.

"import Prelude by default" is now issue #50.

@gelisam
Copy link
Collaborator Author

gelisam commented Aug 16, 2013

the refactoring has introduced a few regressions, but I will create new bugs for them instead of cluttering this thread. closing.

@gelisam gelisam closed this as completed Aug 16, 2013
This was referenced Aug 16, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants