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

replace hardcoded output to file, with output to STDOUT and STDERR #8

Open
mengwong opened this issue Jun 21, 2021 · 2 comments
Open
Assignees

Comments

@mengwong
Copy link
Contributor

mengwong commented Jun 21, 2021

Around line 41 and 42 of https://github.com/smucclaw/sandbox/blob/svg-builder/jacobtan/Rule34-logic-gates/rule34-haskell/src/SandboxBuilder.hs#L41

we see that the script currently writes output to rule34_1.svg and rule34_1_err.svg

I would prefer for the script to output to STDOUT and STDERR, according to the Unix philosophy https://www.usna.edu/Users/cs/wcbrown/courses/IC221/classes/L02/Class.html

If you run the script rule34-svg now, you will see it produces rule34_1.svg:

┌─[mengwong@solo] - [~/src/smucclaw/sandbox/jacobtan/Rule34-logic-gates/rule34-haskell] - [2021-06-21 02:46:58]
└─[0] <git:(svg-builder f2677f3✗✈) > rm *.svg
┌─[mengwong@solo] - [~/src/smucclaw/sandbox/jacobtan/Rule34-logic-gates/rule34-haskell] - [2021-06-21 02:47:00]
└─[0] <git:(svg-builder f2677f3✗✈) > stack exec rule34-svg
┌─[mengwong@solo] - [~/src/smucclaw/sandbox/jacobtan/Rule34-logic-gates/rule34-haskell] - [2021-06-21 02:47:03]
└─[0] <git:(svg-builder f2677f3✗✈) > ls *.svg
rule34_1.svg

After the hardcoding is replaced with outputting to STDOUT and STDERR, we should be able to get the same results, by instead running

stack exec rule34-svg > rule34_1.svg 2> rule34_1_err.svg

Please submit pull request to capture this tweak. Active development is happening in svg-builder so you may want to take a git branch off that, and submit a pull request against the svg-builder branch as base.

In the course of this issue you may find yourself learning more than you ever wanted to know about the difference between stack run and stack exec, and you may need to look up how to get Haskell to write to STDOUT vs STDERR, and you are almost certain to spend time fighting with Git.

@ffrixslee ffrixslee self-assigned this Jun 21, 2021
@2jacobtan
Copy link
Contributor

2jacobtan commented Jun 21, 2021

Probably can refer to this:

https://hackage.haskell.org/package/base-4.15.0.0/docs/System-IO.html#g:19
("Text output" section)

https://hackage.haskell.org/package/base-4.15.0.0/docs/System-IO.html#t:Handle

@ffrixslee ffrixslee mentioned this issue Jun 21, 2021
@ffrixslee
Copy link
Contributor

Probably can refer to this:

https://hackage.haskell.org/package/base-4.15.0.0/docs/System-IO.html#g:19
("Text output" section)

https://hackage.haskell.org/package/base-4.15.0.0/docs/System-IO.html#t:Handle

Thanks @2jacobtan !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants