[Haskell-beginners] How to make this more functional?
Jeffrey Brown
jeffbrown.the at gmail.com
Tue Jul 18 04:10:18 UTC 2017
I wrote a 10-line program[1] for converting from org-mode format to
smsn-mode format. Both formats use indentation to indicate hierarchy. In
org, a line at level k (levels are positive integers) starts with k
asterisks, followed by a space, followed by the text of the line. In
smsn-mode, a line at level k starts with 4*(k-1) spaces, followed by an
asterisks, followed by a space.
I feel like there ought to be an intermediate step where it converts the
data to something other than string -- for instance,
data IndentedLine = IndentedLine Int String | BadLine
and then generates the output from that. It feels like it needs a parser.
But when I resurrect my parser code that I understood many moons ago, it
looks like a lot of machinery.
Thanks.
[1] https://github.com/synchrony/smsn-mode/blob/develop/org-to-smsn-mode.hs
--
Jeff Brown | Jeffrey Benjamin Brown
Website <https://msu.edu/~brown202/> | Facebook
<https://www.facebook.com/mejeff.younotjeff> | LinkedIn
<https://www.linkedin.com/in/jeffreybenjaminbrown>(spammy, so I often miss
messages here) | Github <https://github.com/jeffreybenjaminbrown>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20170717/765e38cf/attachment.html>
More information about the Beginners
mailing list