[Haskell-beginners] order of things in a file.hs?

Jona Ekenberg saikyun at gmail.com
Thu Jun 29 14:47:32 UTC 2017


2017-06-29 16:22 GMT+02:00 Silent Leaf <silent.leaf0 at gmail.com>:

> 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
> Beginners at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20170629/eb51e0f2/attachment-0001.html>


More information about the Beginners mailing list