Subject: [PATCH 2/2] gnu: elm-compiler: Update to 0.19.1.

From: Matthew James Kraai <[email-masked]>
Date: Sat, 7 Aug 2021 21:34:23 -0700

* gnu/packages/elm.scm (elm-compiler): Update to 0.19.1.
[inputs]: Add ghc-filelock.
* gnu/packages/patches/elm-compiler-old-time.patch: New file.
* gnu/packages/patches/elm-compiler-fix-map-key.patch: Delete file.
* gnu/local.mk (dist_patch_DATA): Remove elm-compiler-fix-map-key.patch and
add elm-compiler-old-time.patch.
* gnu/packages/patches/elm-compiler-disable-reactor.patch: Update.
---
 gnu/local.mk                                  |  3 +-
 gnu/packages/elm.scm                          |  8 +-
 .../elm-compiler-disable-reactor.patch        | 84 ++++++++++---------
 .../patches/elm-compiler-fix-map-key.patch    | 38 ---------
 .../patches/elm-compiler-old-time.patch       | 39 +++++++++
 5 files changed, 92 insertions(+), 80 deletions(-)
 delete mode 100644 gnu/packages/patches/elm-compiler-fix-map-key.patch
 create mode 100644 gnu/packages/patches/elm-compiler-old-time.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index caa9090bbd..73bf1409d5 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -44,6 +44,7 @@
 # Copyright © 2021 Arun Isaac <[email-masked]>
 # Copyright © 2021 Sharlatan Hellseher <[email-masked]>
 # Copyright © 2021 Dmitry Polyakov <[email-masked]>
+# Copyright © 2021 Matthew James Kraai <[email-masked]>
 #
 # This file is part of GNU Guix.
 #
@@ -987,7 +988,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/elfutils-tests-ptrace.patch		\
   %D%/packages/patches/elixir-path-length.patch			\
   %D%/packages/patches/elm-compiler-disable-reactor.patch	\
-  %D%/packages/patches/elm-compiler-fix-map-key.patch		\
+  %D%/packages/patches/elm-compiler-old-time.patch		\
   %D%/packages/patches/emacs-exec-path.patch			\
   %D%/packages/patches/emacs-exwm-fix-fullscreen-states.patch	\
   %D%/packages/patches/emacs-fix-scheme-indent-function.patch	\
diff --git a/gnu/packages/elm.scm b/gnu/packages/elm.scm
index feaa9c8d5c..885b0c4b5d 100644
--- a/gnu/packages/elm.scm
+++ b/gnu/packages/elm.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2019 Robert Vollmert <[email-masked]>
+;;; Copyright © 2021 Matthew James Kraai <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -35,7 +36,7 @@
 (define-public elm-compiler
   (package
     (name "elm-compiler")
-    (version "0.19.0")
+    (version "0.19.1")
     (source
      (origin
        (method git-fetch)
@@ -44,10 +45,10 @@
              (url "https://github.com/elm/compiler/")
              (commit version)))
        (sha256
-        (base32 "0s93z9vr0vp5w894ghc5s34nsq09sg1msf59zfiba87sid5vgjqy"))
+        (base32 "1rdg3xp3js9xadclk3cdypkscm5wahgsfmm4ldcw3xswzhw6ri8w"))
        (patches
         (search-patches "elm-compiler-disable-reactor.patch"
-                        "elm-compiler-fix-map-key.patch"))))
+                        "elm-compiler-old-time.patch"))))
     (build-system haskell-build-system)
     (arguments
      `(#:phases
@@ -71,6 +72,7 @@
        ("ghc-ansi-wl-pprint" ,ghc-ansi-wl-pprint)
        ("ghc-edit-distance" ,ghc-edit-distance)
        ("ghc-file-embed" ,ghc-file-embed)
+       ("ghc-filelock" ,ghc-filelock)
        ("ghc-http" ,ghc-http)
        ("ghc-http-client" ,ghc-http-client)
        ("ghc-http-client-tls" ,ghc-http-client-tls)
diff --git a/gnu/packages/patches/elm-compiler-disable-reactor.patch b/gnu/packages/patches/elm-compiler-disable-reactor.patch
index 9871b55e8d..39778c1e93 100644
--- a/gnu/packages/patches/elm-compiler-disable-reactor.patch
+++ b/gnu/packages/patches/elm-compiler-disable-reactor.patch
@@ -1,16 +1,21 @@
-commit 20d80e2323b565a36751c9455e535d8f73fa32f7
-Author: Robert Vollmert <[email-masked]>
-Date:   Fri Jun 14 16:05:47 2019 +0200
+From 15807c24dd5721d6112add7f14f0b70e28f00ca4 Mon Sep 17 00:00:00 2001
+From: Robert Vollmert <[email-masked]>
+Date: Wed, 7 Jul 2021 01:42:20 -0700
+Subject: [PATCH] disable reactor
 
-    disable reactor
+---
+ elm.cabal               |  5 -----
+ terminal/src/Develop.hs | 12 +-----------
+ terminal/src/Main.hs    |  1 -
+ 3 files changed, 1 insertion(+), 17 deletions(-)
 
 diff --git a/elm.cabal b/elm.cabal
-index c75f9689..ece63c46 100644
+index bf1cfcf0..8f7b2bd5 100644
 --- a/elm.cabal
 +++ b/elm.cabal
-@@ -45,9 +45,6 @@ Executable elm
-         builder/src
-         ui/terminal/src
+@@ -48,9 +48,6 @@ Executable elm
+         terminal/impl
+         terminal/src
  
 -    other-extensions:
 -        TemplateHaskell
@@ -18,34 +23,34 @@ index c75f9689..ece63c46 100644
      Main-Is:
          Main.hs
  
-@@ -56,8 +53,6 @@ Executable elm
-         Develop
+@@ -74,8 +71,6 @@ Executable elm
+         -- from terminal/
          Develop.Generate.Help
          Develop.Generate.Index
 -        Develop.StaticFiles
 -        Develop.StaticFiles.Build
-         Diff
-         Init
-         Install
-diff --git a/ui/terminal/src/Develop.hs b/ui/terminal/src/Develop.hs
-index 4b2252e1..7ed7716e 100644
---- a/ui/terminal/src/Develop.hs
-+++ b/ui/terminal/src/Develop.hs
-@@ -23,7 +23,6 @@ import Snap.Util.FileServe
- import qualified Elm.Project as Project
- import qualified Develop.Generate.Help as Generate
+ 
+         -- from builder/
+         Build
+diff --git a/terminal/src/Develop.hs b/terminal/src/Develop.hs
+index 00339364..167de693 100644
+--- a/terminal/src/Develop.hs
++++ b/terminal/src/Develop.hs
+@@ -25,7 +25,6 @@ import qualified Build
+ import qualified Elm.Details as Details
+ import qualified Develop.Generate.Help as Help
  import qualified Develop.Generate.Index as Index
 -import qualified Develop.StaticFiles as StaticFiles
- import qualified Generate.Output as Output
- import qualified Json.Encode as Encode
- import qualified Reporting.Exit as Exit
-@@ -219,16 +218,7 @@ compileToHtmlBuilder mode file =
+ import qualified Generate.Html as Html
+ import qualified Generate
+ import qualified Reporting
+@@ -170,16 +169,7 @@ compile path =

  serveAssets :: Snap ()
 -serveAssets =
--  do  file <- getSafePath
--      case StaticFiles.lookup file of
+-  do  path <- getSafePath
+-      case StaticFiles.lookup path of
 -        Nothing ->
 -          pass
 -
@@ -57,15 +62,18 @@ index 4b2252e1..7ed7716e 100644

  -- MIME TYPES
-diff --git a/ui/terminal/src/Main.hs b/terminal/src/Main.hs
-index 7000f3ca..2c76965a 100644
---- a/ui/terminal/src/Main.hs
-+++ b/ui/terminal/src/Main.hs
-@@ -39,7 +39,6 @@ main =
-       complex intro outro
-         [ repl
-         , init
--        , reactor
-         , make
-         , install
-         , bump
+diff --git a/terminal/src/Main.hs b/terminal/src/Main.hs
+index e2d3f408..cd078422 100644
+--- a/terminal/src/Main.hs
++++ b/terminal/src/Main.hs
+@@ -34,7 +34,6 @@ main =
+   Terminal.app intro outro
+     [ repl
+     , init
+-    , reactor
+     , make
+     , install
+     , bump
+-- 
+2.32.0
+
diff --git a/gnu/packages/patches/elm-compiler-fix-map-key.patch b/gnu/packages/patches/elm-compiler-fix-map-key.patch
deleted file mode 100644
index 4f05ded530..0000000000
--- a/gnu/packages/patches/elm-compiler-fix-map-key.patch
+++ /dev/null
@@ -1,38 +0,0 @@
-commit e3512d887df41a8162c3e361171c04beca08415b
-Author: Tom Stejskal <[email-masked]>
-Date:   Mon Nov 19 20:09:43 2018 +0100
-
-    Fix Map.!: given key is not an element in the map
-
-diff --git a/compiler/src/Elm/Compiler/Type/Extract.hs b/compiler/src/Elm/Compiler/Type/Extract.hs
-index 1aafe1d4..99763392 100644
---- a/compiler/src/Elm/Compiler/Type/Extract.hs
-+++ b/compiler/src/Elm/Compiler/Type/Extract.hs
-@@ -10,6 +10,7 @@ module Elm.Compiler.Type.Extract
- 
- 
- import Data.Map ((!))
-+import qualified Data.Map as Map
- import qualified Data.Maybe as Maybe
- import qualified Data.Set as Set
- 
-@@ -134,11 +135,15 @@ extractUnion interfaces (Opt.Global home name) =
-     else
-       let
-         pname = toPublicName home name
--        unions = I._unions (interfaces ! home)
-+        maybeUnions = I._unions <$> Map.lookup home interfaces
-       in
--      case I.toUnionInternals (unions ! name) of
--        Can.Union vars ctors _ _ ->
--          T.Union pname vars <$> traverse extractCtor ctors
-+      case Map.lookup name =<< maybeUnions of
-+        Just union ->
-+          case I.toUnionInternals union of
-+            Can.Union vars ctors _ _ ->
-+              T.Union pname vars <$> traverse extractCtor ctors
-+        Nothing ->
-+          return $ T.Union pname [] []
- 
- 
- extractCtor :: Can.Ctor -> Extractor (N.Name, [T.Type])
diff --git a/gnu/packages/patches/elm-compiler-old-time.patch b/gnu/packages/patches/elm-compiler-old-time.patch
new file mode 100644
index 0000000000..c5f669a8bf
--- /dev/null
+++ b/gnu/packages/patches/elm-compiler-old-time.patch
@@ -0,0 +1,39 @@
+From 849e80635427f1ff393728d27022cdd672ba82ba Mon Sep 17 00:00:00 2001
+From: Matthew James Kraai <[email-masked]>
+Date: Sat, 7 Aug 2021 21:18:29 -0700
+Subject: [PATCH] Support time < 1.9.1
+
+---
+ builder/src/File.hs | 2 +-
+ elm.cabal           | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/builder/src/File.hs b/builder/src/File.hs
+index 238da083..aaf94369 100644
+--- a/builder/src/File.hs
++++ b/builder/src/File.hs
+@@ -46,7 +46,7 @@ newtype Time = Time Fixed.Pico
+ getTime :: FilePath -> IO Time
+ getTime path =
+   fmap
+-    (Time . Time.nominalDiffTimeToSeconds . Time.utcTimeToPOSIXSeconds)
++    (Time . realToFrac . Time.utcTimeToPOSIXSeconds)
+     (Dir.getModificationTime path)
+ 
+ 
+diff --git a/elm.cabal b/elm.cabal
+index bf1cfcf0..e7afe91e 100644
+--- a/elm.cabal
++++ b/elm.cabal
+@@ -231,7 +231,7 @@ Executable elm
+         snap-core,
+         snap-server,
+         template-haskell,
+-        time >= 1.9.1,
++        time,
+         unordered-containers,
+         utf8-string,
+         vector,
+-- 
+2.32.0
+
-- 
2.32.0