diff --git a/Setup.hs b/Setup.hs
deleted file mode 100644
--- a/Setup.hs
+++ /dev/null
@@ -1,22 +0,0 @@
-#! /usr/bin/env runhaskell
-
-{- Copyright © 2007 Magnus Therning
- -
- - This file is part of dataenc.
- -
- - Dataenc is free software: you can redistribute it and/or modify it under
- - the terms of the GNU Lesser General Public License as published by the
- - Free Software Foundation, either version 3 of the License, or (at your
- - option) any later version.
- -
- - Dataenc is distributed in the hope that it will be useful, but WITHOUT
- - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- - FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
- - License for more details.
- -
- - You should have received a copy of the GNU Lesser General Public License
- - along with dataenc.  If not, see <http://www.gnu.org/licenses/>
- -}
-
-import Distribution.Simple
-main = defaultMain
diff --git a/package.yaml b/package.yaml
new file mode 100644
--- /dev/null
+++ b/package.yaml
@@ -0,0 +1,75 @@
+name: sandi
+version: 0.4.3
+synopsis: Data encoding library
+description: >-
+  Reasonably fast data encoding library.
+maintainer: Magnus Therning <magnus@therning.org>
+license: BSD3
+category: Codec, Conduit
+extra-source-files:
+  - package.yaml
+  - stack.yaml
+  - csrc/*.h
+
+git: https://github.com/magthe/sandi.git
+
+flags:
+  with-conduit:
+    manual: True
+    default: True
+
+library:
+  source-dirs:
+    - src
+  c-sources:
+    - csrc/codec.c
+  cc-options:
+    - -fPIC
+    - -Wall
+    - -Wextra
+  dependencies:
+    - base <5
+    - bytestring
+  when:
+    - condition: flag(with-conduit)
+      dependencies:
+        - conduit
+        - exceptions
+      exposed-modules:
+        - Data.Conduit.Codec.Base16
+        - Data.Conduit.Codec.Base32
+        - Data.Conduit.Codec.Base32Hex
+        - Data.Conduit.Codec.Base64
+        - Data.Conduit.Codec.Base64Url
+        - Data.Conduit.Codec.Base85
+        - Data.Conduit.Codec.QuotedPrintable
+        - Data.Conduit.Codec.Uu
+        - Data.Conduit.Codec.Xx
+        - Data.Conduit.Codec.Yenc
+      other-modules:
+        - Data.Conduit.Codec.Util
+
+tests:
+  sandi-tests:
+    source-dirs:
+      - test-src
+    main: Main.hs
+    dependencies:
+      - sandi
+      - base
+      - bytestring
+      - tasty
+      - tasty-hunit
+      - tasty-quickcheck
+      - tasty-th
+
+benchmarks:
+  sandi-bench:
+    source-dirs:
+      - bench-src
+    main: Main.hs
+    dependencies:
+      - sandi
+      - base
+      - bytestring
+      - criterion
diff --git a/sandi.cabal b/sandi.cabal
--- a/sandi.cabal
+++ b/sandi.cabal
@@ -1,109 +1,121 @@
-name: sandi
-version: 0.4.2
-license: BSD3
-license-file: LICENSE
-cabal-version: >= 1.8
-build-type: Simple
-author: Magnus Therning
-maintainer: magnus@therning.org
-homepage: http://hackage.haskell.org/package/sandi
-copyright: Magnus Therning, 2012
-category: Codec, Conduit
-synopsis: Data encoding library
-description: Reasonably fast data encoding library.
-extra-source-files: csrc/*.h
+-- This file has been generated from package.yaml by hpack version 0.28.2.
+--
+-- see: https://github.com/sol/hpack
+--
+-- hash: b6fde5150c1c8249cec6fdf64ed9a323c10cd14436db56c5d5f8b29a1d26a4bf
 
+name:           sandi
+version:        0.4.3
+synopsis:       Data encoding library
+description:    Reasonably fast data encoding library.
+category:       Codec, Conduit
+maintainer:     Magnus Therning <magnus@therning.org>
+license:        BSD3
+license-file:   LICENSE
+build-type:     Simple
+cabal-version:  >= 1.10
+extra-source-files:
+    csrc/codec.h
+    package.yaml
+    stack.yaml
+
 source-repository head
-    type: git
-    location: https://github.com/magthe/sandi
+  type: git
+  location: https://github.com/magthe/sandi.git
 
 flag with-conduit
-    default: True
-    manual: True
+  manual: True
+  default: True
 
 library
-    hs-source-dirs: src
-    c-sources: csrc/codec.c
-    include-dirs: csrc
-    ghc-options: -Wall
-    cc-options: -fPIC -Wall -Wextra
-    build-depends:
-        base >= 4.7 && < 4.12,
-        bytestring ==0.10.*,
-        stringsearch ==0.3.*
+  exposed-modules:
+      Codec.Binary.Base16
+      Codec.Binary.Base32
+      Codec.Binary.Base32Hex
+      Codec.Binary.Base64
+      Codec.Binary.Base64Url
+      Codec.Binary.Base85
+      Codec.Binary.QuotedPrintable
+      Codec.Binary.Uu
+      Codec.Binary.Xx
+      Codec.Binary.Yenc
+  other-modules:
+      Paths_sandi
+  hs-source-dirs:
+      src
+  cc-options: -fPIC -Wall -Wextra
+  c-sources:
+      csrc/codec.c
+  build-depends:
+      base <5
+    , bytestring
+  if flag(with-conduit)
     exposed-modules:
-        Codec.Binary.Base16
-        Codec.Binary.Base32
-        Codec.Binary.Base32Hex
-        Codec.Binary.Base64
-        Codec.Binary.Base64Url
-        Codec.Binary.Base85
-        Codec.Binary.QuotedPrintable
-        Codec.Binary.Uu
-        Codec.Binary.Xx
-        Codec.Binary.Yenc
-
-    if flag(with-conduit)
-        build-depends:
-            conduit >=1.2 && < 1.4,
-            exceptions >=0.6 && < 0.11
-        exposed-modules:
-            Data.Conduit.Codec.Base16
-            Data.Conduit.Codec.Base32
-            Data.Conduit.Codec.Base32Hex
-            Data.Conduit.Codec.Base64
-            Data.Conduit.Codec.Base64Url
-            Data.Conduit.Codec.Base85
-            Data.Conduit.Codec.QuotedPrintable
-            Data.Conduit.Codec.Uu
-            Data.Conduit.Codec.Xx
-            Data.Conduit.Codec.Yenc
-        other-modules:
-            Data.Conduit.Codec.Util
+        Data.Conduit.Codec.Base16
+        Data.Conduit.Codec.Base32
+        Data.Conduit.Codec.Base32Hex
+        Data.Conduit.Codec.Base64
+        Data.Conduit.Codec.Base64Url
+        Data.Conduit.Codec.Base85
+        Data.Conduit.Codec.QuotedPrintable
+        Data.Conduit.Codec.Uu
+        Data.Conduit.Codec.Xx
+        Data.Conduit.Codec.Yenc
+    other-modules:
+        Data.Conduit.Codec.Util
+    build-depends:
+        conduit
+      , exceptions
+  default-language: Haskell2010
 
 test-suite sandi-tests
-    type: exitcode-stdio-1.0
-    hs-source-dirs: src, test-src
-    build-depends:
-        sandi,
-        base,
-        bytestring,
-        HUnit,
-        tasty,
-        tasty-hunit,
-        tasty-quickcheck,
-        tasty-th
-    main-is: Main.hs
-    other-modules:
-        Codec.Binary.Base16Test
-        Codec.Binary.Base32HexTest
-        Codec.Binary.Base32Test
-        Codec.Binary.Base64Test
-        Codec.Binary.Base64UrlTest
-        Codec.Binary.Base85Test
-        Codec.Binary.QuotedPrintableTest
-        Codec.Binary.UuTest
-        Codec.Binary.XxTest
-        Codec.Binary.YencTest
-        Codec.TestUtils
+  type: exitcode-stdio-1.0
+  main-is: Main.hs
+  other-modules:
+      Codec.Binary.Base16Test
+      Codec.Binary.Base32HexTest
+      Codec.Binary.Base32Test
+      Codec.Binary.Base64Test
+      Codec.Binary.Base64UrlTest
+      Codec.Binary.Base85Test
+      Codec.Binary.QuotedPrintableTest
+      Codec.Binary.UuTest
+      Codec.Binary.XxTest
+      Codec.Binary.YencTest
+      Codec.TestUtils
+      Paths_sandi
+  hs-source-dirs:
+      test-src
+  build-depends:
+      base
+    , bytestring
+    , sandi
+    , tasty
+    , tasty-hunit
+    , tasty-quickcheck
+    , tasty-th
+  default-language: Haskell2010
 
 benchmark sandi-bench
-    type: exitcode-stdio-1.0
-    hs-source-dirs:   src, bench-src
-    build-depends:
-        sandi,
-        base,
-        bytestring,
-        criterion
-    main-is: Main.hs
-    other-modules:
-        Codec.Binary.Base16Bench
-        Codec.Binary.Base32Bench
-        Codec.Binary.Base32HexBench
-        Codec.Binary.Base64Bench
-        Codec.Binary.Base64UrlBench
-        Codec.Binary.Base85Bench
-        Codec.Binary.QuotedPrintableBench
-        Codec.Binary.UuBench
-        Codec.Binary.XxBench
-        Codec.Binary.YencBench
+  type: exitcode-stdio-1.0
+  main-is: Main.hs
+  other-modules:
+      Codec.Binary.Base16Bench
+      Codec.Binary.Base32Bench
+      Codec.Binary.Base32HexBench
+      Codec.Binary.Base64Bench
+      Codec.Binary.Base64UrlBench
+      Codec.Binary.Base85Bench
+      Codec.Binary.QuotedPrintableBench
+      Codec.Binary.UuBench
+      Codec.Binary.XxBench
+      Codec.Binary.YencBench
+      Paths_sandi
+  hs-source-dirs:
+      bench-src
+  build-depends:
+      base
+    , bytestring
+    , criterion
+    , sandi
+  default-language: Haskell2010
diff --git a/stack.yaml b/stack.yaml
new file mode 100644
--- /dev/null
+++ b/stack.yaml
@@ -0,0 +1,10 @@
+resolver: lts-12.16
+
+packages:
+  - '.'
+
+extra-deps: []
+
+flags: {}
+
+extra-package-dbs: []
