diff --git a/LICENSE b/LICENSE
new file mode 100644
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,201 @@
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
diff --git a/hls-rename-plugin.cabal b/hls-rename-plugin.cabal
new file mode 100644
--- /dev/null
+++ b/hls-rename-plugin.cabal
@@ -0,0 +1,50 @@
+cabal-version:      2.4
+name:               hls-rename-plugin
+version:            1.0.0.0
+synopsis:           Rename plugin for Haskell Language Server
+description:
+  Please see the README on GitHub at <https://github.com/haskell/haskell-language-server#readme>
+
+license:            Apache-2.0
+license-file:       LICENSE
+author:             Oliver Madine
+maintainer:         madine.oliver@gmail.com
+category:           Development
+build-type:         Simple
+extra-source-files:
+  LICENSE
+  test/testdata/*.hs
+  test/testdata/*.yaml
+
+library
+  exposed-modules:  Ide.Plugin.Rename
+  hs-source-dirs:   src
+  build-depends:
+    , base                  >=4.12    && <5
+    , containers
+    , extra
+    , ghc
+    , ghc-exactprint
+    , ghcide                >=1.4     && <1.5
+    , hiedb
+    , hls-plugin-api        ^>=1.2
+    , hls-retrie-plugin     >=1.0.1.1
+    , lsp
+    , lsp-types
+    , syb
+    , text
+    , transformers
+
+  default-language: Haskell2010
+
+test-suite tests
+  type:             exitcode-stdio-1.0
+  default-language: Haskell2010
+  hs-source-dirs:   test
+  main-is:          Main.hs
+  ghc-options:      -threaded -rtsopts -with-rtsopts=-N
+  build-depends:
+    , base
+    , filepath
+    , hls-rename-plugin
+    , hls-test-utils             >=1.0 && <1.2
diff --git a/src/Ide/Plugin/Rename.hs b/src/Ide/Plugin/Rename.hs
new file mode 100644
--- /dev/null
+++ b/src/Ide/Plugin/Rename.hs
@@ -0,0 +1,160 @@
+{-# LANGUAGE CPP            #-}
+{-# LANGUAGE DataKinds      #-}
+{-# LANGUAGE GADTs          #-}
+{-# LANGUAGE NamedFieldPuns #-}
+
+module Ide.Plugin.Rename (descriptor) where
+
+import           Control.Monad
+import           Control.Monad.IO.Class               (MonadIO (liftIO))
+import           Control.Monad.Trans.Class
+import           Control.Monad.Trans.Except
+import           Data.Containers.ListUtils
+import           Data.Generics
+import           Data.List.Extra                      hiding (nubOrd)
+import qualified Data.Map                             as M
+import           Data.Maybe
+import qualified Data.Text                            as T
+import           Development.IDE                      hiding (pluginHandlers)
+import           Development.IDE.Core.PositionMapping
+import           Development.IDE.Core.Shake
+import           Development.IDE.GHC.Compat
+import           Development.IDE.Spans.AtPoint
+#if MIN_VERSION_ghc(9,0,1)
+import           GHC.Types.Name
+#else
+import           Name
+#endif
+import           HieDb.Query
+import           Ide.Plugin.Config
+import           Ide.Plugin.Retrie                    hiding (descriptor)
+import           Ide.PluginUtils
+import           Ide.Types
+import           Language.Haskell.GHC.ExactPrint
+import           Language.LSP.Server
+import           Language.LSP.Types
+
+descriptor :: PluginId -> PluginDescriptor IdeState
+descriptor pluginId = (defaultPluginDescriptor pluginId) {
+    pluginHandlers = mkPluginHandler STextDocumentRename renameProvider
+}
+
+renameProvider :: PluginMethodHandler IdeState TextDocumentRename
+renameProvider state pluginId (RenameParams (TextDocumentIdentifier uri) pos _prog newNameText) =
+    response $ do
+        nfp <- safeUriToNfp uri
+        oldName <- getNameAtPos state nfp pos
+        workspaceRefs <- refsAtName state nfp oldName
+        let filesRefs = groupOn locToUri workspaceRefs
+            getFileEdits = ap (getSrcEdits state . renameModRefs newNameText) (locToUri . head)
+
+        fileEdits <- mapM getFileEdits filesRefs
+        pure $ foldl1 (<>) fileEdits
+
+-------------------------------------------------------------------------------
+-- Source renaming
+
+-- | Compute a `WorkspaceEdit` by applying a given function to the `ParsedModule` for a given `Uri`.
+getSrcEdits ::
+    (MonadLsp config m) =>
+    IdeState ->
+#if MIN_VERSION_ghc(9,0,1)
+    (HsModule -> HsModule) ->
+#else
+    (HsModule GhcPs -> HsModule GhcPs) ->
+#endif
+    Uri ->
+    ExceptT String m WorkspaceEdit
+getSrcEdits state updateMod uri = do
+    ccs <- lift getClientCapabilities
+    nfp <- safeUriToNfp uri
+    ParsedModule{pm_parsed_source = ps, pm_annotations = apiAnns} <-
+        handleMaybeM "Error: could not get parsed source" $ liftIO $ runAction
+            "Rename.GetParsedModuleWithComments"
+            state
+            (use GetParsedModuleWithComments nfp)
+
+    let anns = relativiseApiAnns ps apiAnns
+        src = T.pack $ exactPrint ps anns
+        res = T.pack $ exactPrint (updateMod <$> ps) anns
+
+    pure $ diffText ccs (uri, src) res IncludeDeletions
+
+-- | Replace a name at every given `Location` (in a given `HsModule`) with a given new name.
+renameModRefs ::
+    T.Text ->
+    [Location] ->
+#if MIN_VERSION_ghc(9,0,1)
+    HsModule
+    -> HsModule
+#else
+    HsModule GhcPs
+    -> HsModule GhcPs
+#endif
+renameModRefs newNameText refs = everywhere $ mkT replace
+    where
+        replace :: Located RdrName -> Located RdrName
+        replace (L srcSpan oldRdrName)
+            | isRef srcSpan = L srcSpan $ newRdrName oldRdrName
+        replace lOldRdrName = lOldRdrName
+
+        newRdrName :: RdrName -> RdrName
+        newRdrName oldRdrName = case oldRdrName of
+            Qual modName _ -> Qual modName newOccName
+            _              -> Unqual newOccName
+
+        newOccName = mkTcOcc $ T.unpack newNameText
+
+        isRef :: SrcSpan -> Bool
+        isRef = (`elem` refs) . fromJust . srcSpanToLocation
+
+-------------------------------------------------------------------------------
+-- Reference finding
+
+-- | Note: We only find exact name occurences (i.e. type reference "depth" is 0).
+refsAtName :: IdeState -> NormalizedFilePath -> Name -> ExceptT [Char] (LspT Config IO) [Location]
+refsAtName state nfp name = do
+    ShakeExtras{hiedb} <- liftIO $ runAction "Rename.HieDb" state getShakeExtras
+    ast <- safeGetHieAst state nfp
+    astRefs <- handleMaybe "Error: Could not get name AST references" $ getNameAstLocations name ast
+    dbRefs <- case nameModule_maybe name of
+        Nothing -> pure []
+        Just mod -> liftIO $ mapMaybe rowToLoc <$>
+            findReferences
+                hiedb
+                True
+                (nameOccName name)
+                (Just $ moduleName mod)
+                (Just $ moduleUnitId mod)
+                [fromNormalizedFilePath nfp]
+    pure $ nubOrd $ astRefs ++ dbRefs
+
+getNameAstLocations :: Name -> (HieAstResult, PositionMapping) -> Maybe [Location]
+getNameAstLocations name (HAR _ _ rm _ _, mapping) =
+    mapMaybe (toCurrentLocation mapping . realSrcSpanToLocation . fst) <$> M.lookup (Right name) rm
+
+-------------------------------------------------------------------------------
+-- Util
+
+getNameAtPos :: IdeState -> NormalizedFilePath -> Position -> ExceptT String (LspT Config IO) Name
+getNameAtPos state nfp pos = do
+    (HAR{hieAst}, mapping) <- safeGetHieAst state nfp
+    handleMaybe "Error: could not find name at position" $ listToMaybe $
+        getAstNamesAtPoint hieAst pos mapping
+
+nfpToUri :: NormalizedFilePath -> Uri
+nfpToUri = filePathToUri . fromNormalizedFilePath
+
+safeUriToNfp :: (Monad m) => Uri -> ExceptT String m NormalizedFilePath
+safeUriToNfp = handleMaybe "Error: Could not get uri" . fmap toNormalizedFilePath . uriToFilePath
+
+safeGetHieAst ::
+    MonadIO m =>
+    IdeState ->
+    NormalizedFilePath ->
+    ExceptT String m (HieAstResult, PositionMapping)
+safeGetHieAst state = handleMaybeM "Error: Could not get AST" . liftIO .
+    runAction "Rename.GetHieAst" state . useWithStale GetHieAst
+
+locToUri :: Location -> Uri
+locToUri (Location uri _) = uri
diff --git a/test/Main.hs b/test/Main.hs
new file mode 100644
--- /dev/null
+++ b/test/Main.hs
@@ -0,0 +1,60 @@
+{-# LANGUAGE OverloadedStrings #-}
+
+module Main (main) where
+
+import qualified Ide.Plugin.Rename as Rename
+import           System.FilePath
+import           Test.Hls
+
+main :: IO ()
+main = defaultTestRunner tests
+
+renamePlugin :: PluginDescriptor IdeState
+renamePlugin = Rename.descriptor "rename"
+
+tests :: TestTree
+tests = testGroup "Rename"
+    [ goldenWithRename "Data constructor" "DataConstructor" $ \doc -> do
+        rename doc (Position 0 15) "Op"
+    , goldenWithRename "Exported function" "ExportedFunction" $ \doc -> do
+        rename doc (Position 2 1) "quux"
+    , goldenWithRename "Function argument" "FunctionArgument" $ \doc -> do
+        rename doc (Position 3 4) "y"
+    , goldenWithRename "Function name" "FunctionName" $ \doc -> do
+        rename doc (Position 3 1) "baz"
+    , goldenWithRename "GADT" "Gadt" $ \doc -> do
+        rename doc (Position 6 37) "Expr"
+    , goldenWithRename "Hidden function" "HiddenFunction" $ \doc -> do
+        rename doc (Position 0 32) "quux"
+    , goldenWithRename "Imported function" "ImportedFunction" $ \doc -> do
+        rename doc (Position 3 8) "baz"
+    , goldenWithRename "Import hiding" "ImportHiding" $ \doc -> do
+        rename doc (Position 0 22) "hiddenFoo"
+    , goldenWithRename "Let expression" "LetExpression" $ \doc -> do
+        rename doc (Position 5 11) "foobar"
+    , goldenWithRename "Qualified as" "QualifiedAs" $ \doc -> do
+        rename doc (Position 3 10) "baz"
+    , goldenWithRename "Qualified shadowing" "QualifiedShadowing" $ \doc -> do
+        rename doc (Position 3 12) "foobar"
+    , goldenWithRename "Qualified function" "QualifiedFunction" $ \doc -> do
+        rename doc (Position 3 12) "baz"
+    , goldenWithRename "Realigns do block indentation" "RealignDo" $ \doc -> do
+        rename doc (Position 0 2) "fooBarQuux"
+    , goldenWithRename "Record field" "RecordField" $ \doc -> do
+        rename doc (Position 6 9) "number"
+    , goldenWithRename "Shadowed name" "ShadowedName" $ \doc -> do
+        rename doc (Position 1 1) "baz"
+    , goldenWithRename "Typeclass" "Typeclass" $ \doc -> do
+        rename doc (Position 8 15) "Equal"
+    , goldenWithRename "Type constructor" "TypeConstructor" $ \doc -> do
+        rename doc (Position 2 17) "BinaryTree"
+    , goldenWithRename "Type variable" "TypeVariable" $ \doc -> do
+        rename doc (Position 0 13) "b"
+    ]
+
+goldenWithRename :: TestName -> FilePath -> (TextDocumentIdentifier -> Session ()) -> TestTree
+goldenWithRename title path =
+    goldenWithHaskellDoc renamePlugin title testDataDir path "expected" "hs"
+
+testDataDir :: FilePath
+testDataDir = "test" </> "testdata"
diff --git a/test/testdata/DataConstructor.expected.hs b/test/testdata/DataConstructor.expected.hs
new file mode 100644
--- /dev/null
+++ b/test/testdata/DataConstructor.expected.hs
@@ -0,0 +1,4 @@
+data Expr = Op Int Int
+
+plus :: Expr -> Expr
+plus (Op n m) = Op (n + m) 0
diff --git a/test/testdata/DataConstructor.hs b/test/testdata/DataConstructor.hs
new file mode 100644
--- /dev/null
+++ b/test/testdata/DataConstructor.hs
@@ -0,0 +1,4 @@
+data Expr = Apply Int Int
+
+plus :: Expr -> Expr
+plus (Apply n m) = Apply (n + m) 0
diff --git a/test/testdata/ExportedFunction.expected.hs b/test/testdata/ExportedFunction.expected.hs
new file mode 100644
--- /dev/null
+++ b/test/testdata/ExportedFunction.expected.hs
@@ -0,0 +1,5 @@
+module ExportedFunction (quux) where
+
+quux :: Num p => [a] -> p
+quux [] = 0
+quux xs = 1
diff --git a/test/testdata/ExportedFunction.hs b/test/testdata/ExportedFunction.hs
new file mode 100644
--- /dev/null
+++ b/test/testdata/ExportedFunction.hs
@@ -0,0 +1,5 @@
+module ExportedFunction (foo) where
+
+foo :: Num p => [a] -> p
+foo [] = 0
+foo xs = 1
diff --git a/test/testdata/Foo.hs b/test/testdata/Foo.hs
new file mode 100644
--- /dev/null
+++ b/test/testdata/Foo.hs
@@ -0,0 +1,4 @@
+module Foo where
+
+foo :: Int -> Int
+foo x = 0
diff --git a/test/testdata/FunctionArgument.expected.hs b/test/testdata/FunctionArgument.expected.hs
new file mode 100644
--- /dev/null
+++ b/test/testdata/FunctionArgument.expected.hs
@@ -0,0 +1,4 @@
+module FunctionArgument where
+
+foo :: Int -> Int
+foo y = y + 1
diff --git a/test/testdata/FunctionArgument.hs b/test/testdata/FunctionArgument.hs
new file mode 100644
--- /dev/null
+++ b/test/testdata/FunctionArgument.hs
@@ -0,0 +1,4 @@
+module FunctionArgument where
+
+foo :: Int -> Int
+foo x = x + 1
diff --git a/test/testdata/FunctionName.expected.hs b/test/testdata/FunctionName.expected.hs
new file mode 100644
--- /dev/null
+++ b/test/testdata/FunctionName.expected.hs
@@ -0,0 +1,6 @@
+main = do
+    x <- return $ baz 42
+    return (baz x)
+baz, bar :: Int -> Int
+baz x = x + 1
+bar = (+ 1) . baz
diff --git a/test/testdata/FunctionName.hs b/test/testdata/FunctionName.hs
new file mode 100644
--- /dev/null
+++ b/test/testdata/FunctionName.hs
@@ -0,0 +1,6 @@
+main = do
+    x <- return $ foo 42
+    return (foo x)
+foo, bar :: Int -> Int
+foo x = x + 1
+bar = (+ 1) . foo
diff --git a/test/testdata/Gadt.expected.hs b/test/testdata/Gadt.expected.hs
new file mode 100644
--- /dev/null
+++ b/test/testdata/Gadt.expected.hs
@@ -0,0 +1,17 @@
+{-# LANGUAGE GADTs #-}
+
+data Expr a where
+    Number  :: Int -> Expr Int
+    Boolean :: Bool -> Expr Bool
+    Not     :: Expr Bool -> Expr Bool
+    Even    :: Expr Int -> Expr Bool
+    Add     :: Enum a => Expr a -> Expr a -> Expr Int
+    Max     :: Ord a => Expr a -> Expr a -> Expr a
+
+evaluate :: Expr a -> a
+evaluate (Number n)  = n
+evaluate (Boolean p) = p
+evaluate (Add n m)   = fromEnum (evaluate n) + fromEnum (evaluate m)
+evaluate (Even n)    = even $ evaluate n
+evaluate (Not p)     = not $ evaluate p
+evaluate (Max x y)   = max (evaluate x) (evaluate y)
diff --git a/test/testdata/Gadt.hs b/test/testdata/Gadt.hs
new file mode 100644
--- /dev/null
+++ b/test/testdata/Gadt.hs
@@ -0,0 +1,17 @@
+{-# LANGUAGE GADTs #-}
+
+data Expression a where
+    Number  :: Int -> Expression Int
+    Boolean :: Bool -> Expression Bool
+    Not     :: Expression Bool -> Expression Bool
+    Even    :: Expression Int -> Expression Bool
+    Add     :: Enum a => Expression a -> Expression a -> Expression Int
+    Max     :: Ord a => Expression a -> Expression a -> Expression a
+
+evaluate :: Expression a -> a
+evaluate (Number n)  = n
+evaluate (Boolean p) = p
+evaluate (Add n m)   = fromEnum (evaluate n) + fromEnum (evaluate m)
+evaluate (Even n)    = even $ evaluate n
+evaluate (Not p)     = not $ evaluate p
+evaluate (Max x y)   = max (evaluate x) (evaluate y)
diff --git a/test/testdata/HiddenFunction.expected.hs b/test/testdata/HiddenFunction.expected.hs
new file mode 100644
--- /dev/null
+++ b/test/testdata/HiddenFunction.expected.hs
@@ -0,0 +1,4 @@
+import           Foo hiding (quux)
+
+foo :: Int -> Int
+foo x = 0
diff --git a/test/testdata/HiddenFunction.hs b/test/testdata/HiddenFunction.hs
new file mode 100644
--- /dev/null
+++ b/test/testdata/HiddenFunction.hs
@@ -0,0 +1,4 @@
+import           Foo hiding (foo)
+
+foo :: Int -> Int
+foo x = 0
diff --git a/test/testdata/ImportHiding.expected.hs b/test/testdata/ImportHiding.expected.hs
new file mode 100644
--- /dev/null
+++ b/test/testdata/ImportHiding.expected.hs
@@ -0,0 +1,4 @@
+import Foo hiding (hiddenFoo)
+
+foo :: Int -> Int
+foo _ = 5
diff --git a/test/testdata/ImportHiding.hs b/test/testdata/ImportHiding.hs
new file mode 100644
--- /dev/null
+++ b/test/testdata/ImportHiding.hs
@@ -0,0 +1,4 @@
+import Foo hiding (foo)
+
+foo :: Int -> Int
+foo _ = 5
diff --git a/test/testdata/ImportedFunction.expected.hs b/test/testdata/ImportedFunction.expected.hs
new file mode 100644
--- /dev/null
+++ b/test/testdata/ImportedFunction.expected.hs
@@ -0,0 +1,4 @@
+import           Foo (baz)
+
+bar :: Int -> Int
+bar = baz
diff --git a/test/testdata/ImportedFunction.hs b/test/testdata/ImportedFunction.hs
new file mode 100644
--- /dev/null
+++ b/test/testdata/ImportedFunction.hs
@@ -0,0 +1,4 @@
+import           Foo (foo)
+
+bar :: Int -> Int
+bar = foo
diff --git a/test/testdata/LetExpression.expected.hs b/test/testdata/LetExpression.expected.hs
new file mode 100644
--- /dev/null
+++ b/test/testdata/LetExpression.expected.hs
@@ -0,0 +1,10 @@
+module Let where
+
+import Foo
+
+bar :: Int
+bar = let foobar = 5 in
+    foobar * foobar
+
+quux :: Int
+quux = Foo.foo 4
diff --git a/test/testdata/LetExpression.hs b/test/testdata/LetExpression.hs
new file mode 100644
--- /dev/null
+++ b/test/testdata/LetExpression.hs
@@ -0,0 +1,10 @@
+module Let where
+
+import Foo
+
+bar :: Int
+bar = let foo = 5 in
+    foo * foo
+
+quux :: Int
+quux = Foo.foo 4
diff --git a/test/testdata/QualifiedAs.expected.hs b/test/testdata/QualifiedAs.expected.hs
new file mode 100644
--- /dev/null
+++ b/test/testdata/QualifiedAs.expected.hs
@@ -0,0 +1,4 @@
+import qualified Foo as F
+
+bar :: Int -> Int
+bar = F.baz
diff --git a/test/testdata/QualifiedAs.hs b/test/testdata/QualifiedAs.hs
new file mode 100644
--- /dev/null
+++ b/test/testdata/QualifiedAs.hs
@@ -0,0 +1,4 @@
+import qualified Foo as F
+
+bar :: Int -> Int
+bar = F.foo
diff --git a/test/testdata/QualifiedFunction.expected.hs b/test/testdata/QualifiedFunction.expected.hs
new file mode 100644
--- /dev/null
+++ b/test/testdata/QualifiedFunction.expected.hs
@@ -0,0 +1,4 @@
+import qualified Foo
+
+bar :: Int -> Int
+bar = Foo.baz
diff --git a/test/testdata/QualifiedFunction.hs b/test/testdata/QualifiedFunction.hs
new file mode 100644
--- /dev/null
+++ b/test/testdata/QualifiedFunction.hs
@@ -0,0 +1,4 @@
+import qualified Foo
+
+bar :: Int -> Int
+bar = Foo.foo
diff --git a/test/testdata/QualifiedShadowing.expected.hs b/test/testdata/QualifiedShadowing.expected.hs
new file mode 100644
--- /dev/null
+++ b/test/testdata/QualifiedShadowing.expected.hs
@@ -0,0 +1,7 @@
+import qualified Foo as F
+
+bar :: Int -> Int
+bar x = F.foobar x + foo x
+
+foo :: Int -> Int
+foo _ = 5
diff --git a/test/testdata/QualifiedShadowing.hs b/test/testdata/QualifiedShadowing.hs
new file mode 100644
--- /dev/null
+++ b/test/testdata/QualifiedShadowing.hs
@@ -0,0 +1,7 @@
+import qualified Foo as F
+
+bar :: Int -> Int
+bar x = F.foo x + foo x
+
+foo :: Int -> Int
+foo _ = 5
diff --git a/test/testdata/RealignDo.expected.hs b/test/testdata/RealignDo.expected.hs
new file mode 100644
--- /dev/null
+++ b/test/testdata/RealignDo.expected.hs
@@ -0,0 +1,4 @@
+fooBarQuux :: Maybe Integer
+fooBarQuux = do x <- Just 5
+                t <- Just 10
+                pure $ x + t
diff --git a/test/testdata/RealignDo.hs b/test/testdata/RealignDo.hs
new file mode 100644
--- /dev/null
+++ b/test/testdata/RealignDo.hs
@@ -0,0 +1,4 @@
+foo :: Maybe Integer
+foo = do x <- Just 5
+         t <- Just 10
+         pure $ x + t
diff --git a/test/testdata/RecordField.expected.hs b/test/testdata/RecordField.expected.hs
new file mode 100644
--- /dev/null
+++ b/test/testdata/RecordField.expected.hs
@@ -0,0 +1,7 @@
+data Bam = Bam {
+    number :: Int,
+    s :: String
+}
+
+foo :: Bam -> Bam
+foo Bam {number = y} = Bam {number = y + 5, s = ""}
diff --git a/test/testdata/RecordField.hs b/test/testdata/RecordField.hs
new file mode 100644
--- /dev/null
+++ b/test/testdata/RecordField.hs
@@ -0,0 +1,7 @@
+data Bam = Bam {
+    n :: Int,
+    s :: String
+}
+
+foo :: Bam -> Bam
+foo Bam {n = y} = Bam {n = y + 5, s = ""}
diff --git a/test/testdata/ShadowedName.expected.hs b/test/testdata/ShadowedName.expected.hs
new file mode 100644
--- /dev/null
+++ b/test/testdata/ShadowedName.expected.hs
@@ -0,0 +1,4 @@
+baz :: Int -> Int
+baz x = foo + 10
+    where
+        foo = 20
diff --git a/test/testdata/ShadowedName.hs b/test/testdata/ShadowedName.hs
new file mode 100644
--- /dev/null
+++ b/test/testdata/ShadowedName.hs
@@ -0,0 +1,4 @@
+foo :: Int -> Int
+foo x = foo + 10
+    where
+        foo = 20
diff --git a/test/testdata/TypeConstructor.expected.hs b/test/testdata/TypeConstructor.expected.hs
new file mode 100644
--- /dev/null
+++ b/test/testdata/TypeConstructor.expected.hs
@@ -0,0 +1,5 @@
+data BinaryTree a = Node a (BinaryTree a) (BinaryTree a) | Leaf a
+
+rotateRight :: BinaryTree a -> BinaryTree a
+rotateRight (Node v (Node v' l' r') r) =  Node v' l' (Node v r' r)
+rotateRight t                          = t
diff --git a/test/testdata/TypeConstructor.hs b/test/testdata/TypeConstructor.hs
new file mode 100644
--- /dev/null
+++ b/test/testdata/TypeConstructor.hs
@@ -0,0 +1,5 @@
+data Tree a = Node a (Tree a) (Tree a) | Leaf a
+
+rotateRight :: Tree a -> Tree a
+rotateRight (Node v (Node v' l' r') r) =  Node v' l' (Node v r' r)
+rotateRight t                          = t
diff --git a/test/testdata/TypeVariable.expected.hs b/test/testdata/TypeVariable.expected.hs
new file mode 100644
--- /dev/null
+++ b/test/testdata/TypeVariable.expected.hs
@@ -0,0 +1,2 @@
+bar :: Maybe b -> Maybe b
+bar a = a
diff --git a/test/testdata/TypeVariable.hs b/test/testdata/TypeVariable.hs
new file mode 100644
--- /dev/null
+++ b/test/testdata/TypeVariable.hs
@@ -0,0 +1,2 @@
+bar :: Maybe a -> Maybe a
+bar a = a
diff --git a/test/testdata/Typeclass.expected.hs b/test/testdata/Typeclass.expected.hs
new file mode 100644
--- /dev/null
+++ b/test/testdata/Typeclass.expected.hs
@@ -0,0 +1,10 @@
+module Typeclass where
+
+class Equal a where
+    equals :: a -> a -> Bool
+
+instance Equal Int where
+  equals = (==)
+
+allEqual :: Equal a => [a] -> Bool
+allEqual = all =<< equals . head
diff --git a/test/testdata/Typeclass.hs b/test/testdata/Typeclass.hs
new file mode 100644
--- /dev/null
+++ b/test/testdata/Typeclass.hs
@@ -0,0 +1,10 @@
+module Typeclass where
+
+class Equality a where
+    equals :: a -> a -> Bool
+
+instance Equality Int where
+  equals = (==)
+
+allEqual :: Equality a => [a] -> Bool
+allEqual = all =<< equals . head
diff --git a/test/testdata/hie.yaml b/test/testdata/hie.yaml
new file mode 100644
--- /dev/null
+++ b/test/testdata/hie.yaml
@@ -0,0 +1,22 @@
+cradle:
+  direct:
+    arguments:
+      - "DataConstructor"
+      - "ExportedFunction"
+      - "Foo"
+      - "FunctionArgument"
+      - "FunctionName"
+      - "Gadt"
+      - "HiddenFunction"
+      - "ImportHiding"
+      - "ImportedFunction"
+      - "LetExpression"
+      - "QualifiedAs"
+      - "QualifiedFunction"
+      - "QualifiedShadowing"
+      - "RealignDo"
+      - "RecordField"
+      - "ShadowedName"
+      - "TypeClass"
+      - "TypeConstructor"
+      - "TypeVariable"
