order of things in a file.hs?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

order of things in a file.hs?

Silent Leaf
hi,

what is your personal practice of ordering data/functions/main/hidden functions, etc in a haskell file? like all trivial things they are very hard to decide upon, given that either order of helpers then main function / value, or the other way round, has tempting pros and cons.

thanks in advance for your opinion!

_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: order of things in a file.hs?

Norbert Melzer

In all languages that support arbitrary ordering I try to keep exported stuff to the top and private stuff somewhere below.


Silent Leaf <[hidden email]> schrieb am Do., 29. Juni 2017, 16:23:
hi,

what is your personal practice of ordering data/functions/main/hidden functions, etc in a haskell file? like all trivial things they are very hard to decide upon, given that either order of helpers then main function / value, or the other way round, has tempting pros and cons.

thanks in advance for your opinion!
_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners

_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: order of things in a file.hs?

Jona Ekenberg
In reply to this post by Silent Leaf


2017-06-29 16:22 GMT+02:00 Silent Leaf <[hidden email]>:
hi,

what is your personal practice of ordering data/functions/main/hidden functions, etc in a haskell file? like all trivial things they are very hard to decide upon, given that either order of helpers then main function / value, or the other way round, has tempting pros and cons.

thanks in advance for your opinion!


I've started trying to write my program in a way that makes sense as when reading it from top to bottom, like a story.
So if you write a function that calls upon other functions, those functions can come immediately afterwards, if they're relevant, or if their names are enough, they could be put in a different file altogether.
Some functions are bigger, like stories of their own. In those cases I generally put them in a new file, like a new chapter. Those should be coherent in themselves, and not depend on the first file in order to make sense. If chapters are dependent on each other in that way, then maybe they have to be rewritten.

This is a really course generalization, and I've actually not written code like this for long. But I do think writing code in a way that makes sense as a human reader is important, and humans tend to enjoy reading stories. It doesn't really have to be some sort of magical journey (though it very well could be!), but I think there should be some sort of red thread that goes from one place in the code to the next, without extreme leaps that are hard to understand.
 
_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners



_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
Loading...