diff --git a/THANKS.md b/THANKS.md
--- a/THANKS.md
+++ b/THANKS.md
@@ -160,7 +160,7 @@
 - Denis Laxalde separated the gsl tests from the base ones.
 
 - Dominic Steinitz (idontgetoutmuch) reported a bug in the static diagonal creation functions and
-  added Cholesky to Static. He also added support for tridiagonal matrix solver.
+  added Cholesky to Static. He also added support for tridiagonal matrix solver and fixed several bugs.
 
 - Dylan Thurston reported an error in the glpk documentation and ambiguity in
   the description of linearSolve.
@@ -171,7 +171,7 @@
 - Ian Ross reported the max/minIndex bug.
 
 - Niklas Hambüchen improved the documentation and fixed compilation with GHC-8.2
-  adding type signatures.
+  adding type signatures. Added disable-default-paths flag.
 
 - "erdeszt" optimized "conv" using a direct vector reverse.
 
@@ -231,4 +231,6 @@
 - "fedeinthemix" suggested a better name and a more general type for unitary.
 
 - Huw Campbell fixed a bug in equal.
+
+- Hiromi Ishii fixed compilation problems for ghc-8.4
 
diff --git a/hmatrix.cabal b/hmatrix.cabal
--- a/hmatrix.cabal
+++ b/hmatrix.cabal
@@ -1,5 +1,5 @@
 Name:               hmatrix
-Version:            0.18.1.0
+Version:            0.18.2.0
 License:            BSD3
 License-file:       LICENSE
 Author:             Alberto Ruiz
@@ -16,7 +16,7 @@
                     Code examples: <http://dis.um.es/~alberto/hmatrix/hmatrix.html>
 
 Category:           Math
-tested-with:        GHC==8.0
+tested-with:        GHC==8.2, GHC==8.4
 
 cabal-version:      >=1.8
 
@@ -31,6 +31,11 @@
     default:        False
     manual: True
 
+flag disable-default-paths
+    description:    When enabled, don't add default hardcoded include/link dirs by default. Needed for hermetic builds like in nix.
+    default:        False
+    manual: True
+
 library
 
     Build-Depends:      base >= 4.8 && < 5,
@@ -41,6 +46,7 @@
                         split,
                         bytestring,
                         storable-complex,
+                        semigroups,
                         vector >= 0.8
 
     hs-source-dirs:     src
@@ -95,29 +101,33 @@
 
     if os(OSX)
         if flag(openblas)
-            extra-lib-dirs:     /opt/local/lib/openblas/lib
+            if !flag(disable-default-paths)
+                extra-lib-dirs:     /opt/local/lib/openblas/lib
             extra-libraries:    openblas
         else
             extra-libraries:    blas lapack
 
-        extra-lib-dirs: /opt/local/lib/
-        include-dirs: /opt/local/include/
-        extra-lib-dirs: /usr/local/lib/
-        include-dirs: /usr/local/include/
+        if !flag(disable-default-paths)
+            extra-lib-dirs: /opt/local/lib/
+            include-dirs: /opt/local/include/
+            extra-lib-dirs: /usr/local/lib/
+            include-dirs: /usr/local/include/
         if arch(i386)
             cc-options: -arch i386
         frameworks: Accelerate
 
     if os(freebsd)
         if flag(openblas)
-            extra-lib-dirs:     /usr/local/lib/openblas/lib
+            if !flag(disable-default-paths)
+                extra-lib-dirs:     /usr/local/lib/openblas/lib
             extra-libraries:    openblas
         else
             extra-libraries:    blas lapack
 
-       extra-lib-dirs: /usr/local/lib
-       include-dirs: /usr/local/include
-       extra-libraries: gfortran
+        if !flag(disable-default-paths)
+            extra-lib-dirs: /usr/local/lib
+            include-dirs: /usr/local/include
+        extra-libraries: gfortran
 
     if os(windows)
         if flag(openblas)
@@ -127,7 +137,8 @@
 
     if os(linux)
         if flag(openblas)
-            extra-lib-dirs:     /usr/lib/openblas/lib
+            if !flag(disable-default-paths)
+                extra-lib-dirs:     /usr/lib/openblas/lib
             extra-libraries:    openblas
         else
             extra-libraries:    blas lapack
diff --git a/src/Internal/Container.hs b/src/Internal/Container.hs
--- a/src/Internal/Container.hs
+++ b/src/Internal/Container.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE CPP #-}
 {-# LANGUAGE FlexibleContexts #-}
 {-# LANGUAGE FlexibleInstances #-}
 {-# LANGUAGE MultiParamTypeClasses #-}
@@ -29,7 +30,9 @@
 import Internal.Element
 import Internal.Numeric
 import Internal.Algorithms(Field,linearSolveSVD,Herm,mTm)
-
+#if MIN_VERSION_base(4,11,0)
+import Prelude hiding ((<>))
+#endif
 ------------------------------------------------------------------
 
 {- | Creates a real vector containing a range of values:
diff --git a/src/Internal/Convolution.hs b/src/Internal/Convolution.hs
--- a/src/Internal/Convolution.hs
+++ b/src/Internal/Convolution.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE CPP #-}
 {-# LANGUAGE FlexibleContexts #-}
 -----------------------------------------------------------------------------
 {- |
@@ -23,6 +24,9 @@
 import Internal.Element
 import Internal.Conversion
 import Internal.Container
+#if MIN_VERSION_base(4,11,0)
+import Prelude hiding ((<>))
+#endif
 
 
 vectSS :: Element t => Int -> Vector t -> Matrix t
diff --git a/src/Internal/Modular.hs b/src/Internal/Modular.hs
--- a/src/Internal/Modular.hs
+++ b/src/Internal/Modular.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE CPP #-}
 {-# LANGUAGE DataKinds #-}
 {-# LANGUAGE KindSignatures #-}
 {-# LANGUAGE GeneralizedNewtypeDeriving #-}
@@ -38,13 +39,20 @@
                      gaussElim, gaussElim_1, gaussElim_2,
                      luST, luSolve', luPacked', magnit, invershur)
 import Internal.ST(mutable)
+#if MIN_VERSION_base(4,11,0)
+import GHC.TypeLits hiding (Mod)
+#else
 import GHC.TypeLits
+#endif
 import Data.Proxy(Proxy)
 import Foreign.ForeignPtr(castForeignPtr)
 import Foreign.Storable
 import Data.Ratio
 import Data.Complex
 import Control.DeepSeq ( NFData(..) )
+#if MIN_VERSION_base(4,11,0)
+import Prelude hiding ((<>))
+#endif
 
 
 
diff --git a/src/Internal/Util.hs b/src/Internal/Util.hs
--- a/src/Internal/Util.hs
+++ b/src/Internal/Util.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE CPP #-}
 {-# LANGUAGE FlexibleContexts #-}
 {-# LANGUAGE FlexibleInstances #-}
 {-# LANGUAGE MultiParamTypeClasses #-}
@@ -80,6 +81,9 @@
 import Data.Complex
 import Data.Function(on)
 import Internal.ST
+#if MIN_VERSION_base(4,11,0)
+import Prelude hiding ((<>))
+#endif
 
 type ℝ = Double
 type ℕ = Int
diff --git a/src/Numeric/LinearAlgebra.hs b/src/Numeric/LinearAlgebra.hs
--- a/src/Numeric/LinearAlgebra.hs
+++ b/src/Numeric/LinearAlgebra.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE CPP #-}
 {-# LANGUAGE FlexibleContexts #-}
 
 -----------------------------------------------------------------------------
@@ -190,6 +191,9 @@
 import Internal.Sparse((!#>))
 import Internal.CG
 import Internal.Conversion
+#if MIN_VERSION_base(4,11,0)
+import Prelude hiding ((<>))
+#endif
 
 {- | dense matrix product
 
diff --git a/src/Numeric/LinearAlgebra/HMatrix.hs b/src/Numeric/LinearAlgebra/HMatrix.hs
--- a/src/Numeric/LinearAlgebra/HMatrix.hs
+++ b/src/Numeric/LinearAlgebra/HMatrix.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE CPP #-}
 --------------------------------------------------------------------------------
 {- |
 Module      :  Numeric.LinearAlgebra.HMatrix
@@ -19,6 +20,9 @@
 import Numeric.LinearAlgebra
 import Internal.Util
 import Internal.Algorithms(cholSH, mbCholSH, eigSH', eigenvaluesSH', geigSH')
+#if MIN_VERSION_base(4,11,0)
+import Prelude hiding ((<>))
+#endif
 
 infixr 8 <·>
 (<·>) :: Numeric t => Vector t -> Vector t -> t
diff --git a/src/Numeric/LinearAlgebra/Static.hs b/src/Numeric/LinearAlgebra/Static.hs
--- a/src/Numeric/LinearAlgebra/Static.hs
+++ b/src/Numeric/LinearAlgebra/Static.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE CPP #-}
 {-# LANGUAGE DataKinds #-}
 {-# LANGUAGE KindSignatures #-}
 {-# LANGUAGE GeneralizedNewtypeDeriving #-}
@@ -80,6 +81,9 @@
 import Text.Printf
 import Data.Type.Equality ((:~:)(Refl))
 import qualified Data.Bifunctor as BF (first)
+#if MIN_VERSION_base(4,11,0)
+import Prelude hiding ((<>))
+#endif
 
 ud1 :: R n -> Vector ℝ
 ud1 (R (Dim v)) = v
@@ -214,11 +218,11 @@
 
 
 infixr 8 <·>
-(<·>) :: R n -> R n -> ℝ
+(<·>) :: KnownNat n => R n -> R n -> ℝ
 (<·>) = dotR
 
 infixr 8 <.>
-(<.>) :: R n -> R n -> ℝ
+(<.>) :: KnownNat n => R n -> R n -> ℝ
 (<.>) = dotR
 
 --------------------------------------------------------------------------------
@@ -601,10 +605,8 @@
 appR m v = mkR (extract m LA.#> extract v)
 
 
-dotR :: R n -> R n -> ℝ
-dotR (ud1 -> u) (ud1 -> v)
-    | singleV u || singleV v = sumElements (u * v)
-    | otherwise = udot u v
+dotR :: KnownNat n => R n -> R n -> ℝ
+dotR (extract -> u) (extract -> v) = LA.dot u v
 
 
 crossR :: R 3 -> R 3 -> R 3
@@ -667,9 +669,7 @@
 
 
 dotC :: KnownNat n => C n -> C n -> ℂ
-dotC (unwrap -> u) (unwrap -> v)
-    | singleV u || singleV v = sumElements (conj u * v)
-    | otherwise = u LA.<.> v
+dotC (extract -> u) (extract -> v) = LA.dot u v
 
 
 crossC :: C 3 -> C 3 -> C 3
diff --git a/src/Numeric/Matrix.hs b/src/Numeric/Matrix.hs
--- a/src/Numeric/Matrix.hs
+++ b/src/Numeric/Matrix.hs
@@ -32,8 +32,11 @@
 import Internal.Numeric
 import qualified Data.Monoid as M
 import Data.List(partition)
+import qualified Data.Foldable as F
+import qualified Data.Semigroup as S
 import Internal.Chain
 
+
 -------------------------------------------------------------------
 
 instance Container Matrix a => Eq (Matrix a) where
@@ -83,6 +86,11 @@
     | isScalar x = f1   (x @@>(0,0) ) y
     | isScalar y = f3 x (y @@>(0,0) )
     | otherwise = f2 x y
+
+instance (Container Vector t, Eq t, Num (Vector t), Product t) => S.Semigroup (Matrix t)
+  where
+    (<>) = mappend
+    sconcat = mconcat . F.toList
 
 instance (Container Vector t, Eq t, Num (Vector t), Product t) => M.Monoid (Matrix t)
   where
