Subject: [bug#48813] [PATCH 8/8] gnu: Add ghc-brittany.

From: Xinglu Chen <[email-masked]>
Date: Thu, 03 Jun 2021 17:58:12 +0200

* gnu/packages/haskell-xyz.scm (ghc-brittany): New variable.
---
 gnu/packages/haskell-xyz.scm | 126 +++++++++++++++++++++++++++++++++++
 1 file changed, 126 insertions(+)

diff --git a/gnu/packages/haskell-xyz.scm b/gnu/packages/haskell-xyz.scm
index 446e60477b..ee54a65332 100644
--- a/gnu/packages/haskell-xyz.scm
+++ b/gnu/packages/haskell-xyz.scm
@@ -1211,6 +1211,132 @@ interface.")
 using a simple box model.")
     (license license:bsd-3)))
 
+(define-public ghc-brittany
+  (package
+    (name "ghc-brittany")
+    (version "0.12.1.1")
+    (source
+      (origin
+        (method url-fetch)
+        (uri (string-append
+               "https://hackage.haskell.org/package/brittany/brittany-"
+               version
+               ".tar.gz"))
+        (sha256
+          (base32
+            "0nw7ymdb7xam634w42l1xjgyvpla8grcg02aj19fscw2fn9gfh7z"))))
+    (build-system haskell-build-system)
+    (inputs
+      `(("ghc-paths" ,ghc-paths)
+        ("ghc-exactprint" ,ghc-exactprint)
+        ("ghc-multistate" ,ghc-multistate)
+        ("ghc-syb" ,ghc-syb)
+        ("ghc-neat-interpolation"
+         ,ghc-neat-interpolation)
+        ("ghc-data-tree-print" ,ghc-data-tree-print)
+        ("ghc-butcher" ,ghc-butcher)
+        ("ghc-yaml" ,ghc-yaml)
+        ("ghc-aeson" ,ghc-aeson)
+        ("ghc-extra" ,ghc-extra)
+        ("ghc-uniplate" ,ghc-uniplate)
+        ("ghc-strict" ,ghc-strict)
+        ("ghc-monad-memo" ,ghc-monad-memo)
+        ("ghc-unsafe" ,ghc-unsafe)
+        ("ghc-safe" ,ghc-safe)
+        ("ghc-semigroups" ,ghc-semigroups)
+        ("ghc-cmdargs" ,ghc-cmdargs)
+        ("ghc-czipwith" ,ghc-czipwith)
+        ("ghc-random" ,ghc-random)))
+    (native-inputs
+      `(("ghc-hspec" ,ghc-hspec)
+        ("ghc-hspec" ,ghc-hspec)
+        ("ghc-hspec" ,ghc-hspec)))
+    (arguments
+      `(#:cabal-revision
+        ("2"
+         "0pfrm5vvh7x94f8gy8ka6rmq6yk6xxxgba68rd91bk8lbjxsmkxl")))
+    (home-page "https://github.com/lspitzner/brittany/")
+    (synopsis "Haskell source code formatter")
+    (description "Brittany is a Haskell source code formatter.  The goal of
+this project is to:
+
+@itemize
+@item
+Always retain the semantics of the source being transformed;
+@item
+Be idempotent;
+@item
+Support the full GHC-haskell syntax including syntactic extensions (but
+excluding -XCPP which is too hard);
+@item
+Retain newlines and comments unmodified;
+@item
+Be clever about using the available horizontal space while not overflowing the
+column maximum unless it cannot be avoided;
+@item
+Be clever about aligning things horizontally (this can be turned off
+completely however);
+@item
+Have linear complexity in the size of the input.
+@end itemize")
+    (license license:agpl3)))
+
+(define-public ghc-butcher
+  (package
+    (name "ghc-butcher")
+    (version "1.3.2.3")
+    (source
+      (origin
+        (method url-fetch)
+        (uri (string-append
+               "https://hackage.haskell.org/package/butcher/butcher-"
+               version
+               ".tar.gz"))
+        (sha256
+          (base32
+            "0lpicayq9k59m2ydz989xsypr653xwhp6mmhlp7nmjzk6jwpq5q5"))))
+    (build-system haskell-build-system)
+    (inputs
+      `(("ghc-free" ,ghc-free)
+        ("ghc-unsafe" ,ghc-unsafe)
+        ("ghc-microlens" ,ghc-microlens)
+        ("ghc-microlens-th" ,ghc-microlens-th)
+        ("ghc-multistate" ,ghc-multistate)
+        ("ghc-extra" ,ghc-extra)
+        ("ghc-void" ,ghc-void)
+        ("ghc-bifunctors" ,ghc-bifunctors)
+        ("ghc-deque" ,ghc-deque)))
+    (native-inputs `(("ghc-hspec" ,ghc-hspec)))
+    (arguments
+      `(#:cabal-revision
+        ("2"
+         "1751sllw8s81x3s1dhilbr5lqnv9cpdqiv17c8by466aa6304dxa")))
+    (home-page "https://github.com/lspitzner/butcher/")
+    (synopsis "Chops a command or program invocation into digestable pieces.")
+    (description "This package is similar to the optparse-applicative package,
+but less features, more flexibility and more evil.
+
+The main differences are:
+
+@itemize
+@item Provides a pure interface by default
+
+@item Exposes an evil monadic interface, which allows for much nicer binding
+of command part results to some variable name.
+
+In optparse-applicative you easily lose track of what field you are modifying
+after the 5th <*> (admittedly, i think -XRecordWildCards improves on that
+issue already.)
+
+Evil, because you are not allowed to use the monad's full power in this case,
+i.e. there is a constraint that is not statically enforced. See below.
+
+@item The monadic interface allows much clearer definitions of commandparses
+with (nested) subcommands. No pesky sum-types are necessary.
+@end itemize")
+
+    (license license:bsd-3)))
+
 (define-public ghc-byteable
   (package
     (name "ghc-byteable")
-- 
2.31.1