simple-src-utils: source code editing utilities

[ bsd3, development, haskell, program ] [ Propose Tags ] [ Report a vulnerability ]

Collection of small utilities to manipulate source code.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1
Dependencies base (>=3 && <5), extra, text [details]
Tested with ghc ==7.8.4, ghc ==7.10.3, ghc ==8.0.2, ghc ==8.2.2, ghc ==8.4.1
License BSD-3-Clause
Author Evan Laforge
Maintainer Evan Laforge <qdunkan@gmail.com>
Category Haskell, Development
Home page https://github.com/elaforge/simple-src-utils
Source repo head: git clone git://github.com/elaforge/simple-src-utils.git
Uploaded by EvanLaforge at 2018-04-07T16:11:34Z
Distributions NixOS:0.1
Reverse Dependencies 1 direct, 0 indirect [details]
Executables cmt, string-literal
Downloads 897 total (5 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs not available [build log]
Last success reported on 2021-06-02 [all 1 reports]

Readme for simple-src-utils-0.1

[back to package description]

Some small source code manipulation tools I use with vim. They're external filters, though, so if you use acme instead of vim, they should work fine there too. See included vimrc for examples.

  • cmt - Comment and uncomment code.

  • string-literal - Toggle between raw text and list of lines or Haskell backslash string gap style. Copy paste from its usage:

string-literal [ --wrapped --{add,remove,toggle}-{backslash,lines} ]

Convert between plain text and either backslash-continued string literals, or list of lines style strings. This is to work around haskell's lack of multi-line string literals. Bind the toggle variant to a vim key to switch between raw text and haskell string literal.

It assumes a single level of indent for the strings, and leaves the indent even in the raw form, so that the text will continue to fit in more or less the same number of columns. This means they will look a bit short if printed literally on the terminal, but if you care about that, use --wrapped mode and have some terminal-aware layer do the wrapping.

--wrapped mode assumes that someone else will be wrapping the text. It doesn't put in newlines, and separates wrapped with a leading space. A paragraph newline in the input becomes an explicit newline in the haskell string. Since it assumes someone else is wrapping, it won't preserve your own leading spaces. If you are doing explicit formatting then don't use --wrapped.

Standard CPP doesn't like Haskell string-gap syntax. You can either use cpphs via -pgmP 'cpphs --cpp', or use lines mode, which is more cluttered but doesn't make CPP mad. Presumably you have a unlines or Text.unlines call at the front of the list.