diff --git a/bench/Data/Mutable/Array.hs b/bench/Bench/Data/Array/Mutable.hs similarity index 99% rename from bench/Data/Mutable/Array.hs rename to bench/Bench/Data/Array/Mutable.hs index 3d1fc557..c98bb165 100644 --- a/bench/Data/Mutable/Array.hs +++ b/bench/Bench/Data/Array/Mutable.hs @@ -11,7 +11,7 @@ -- land in a file named “Array.dump-simpl” -- {-# OPTIONS_GHC -ddump-simpl -ddump-to-file -dsuppress-all -dsuppress-uniques #-} -module Data.Mutable.Array (benchmarks) where +module Bench.Data.Array.Mutable (benchmarks) where import Control.DeepSeq (rnf) import qualified Data.Array.Mutable.Linear as Array.Linear diff --git a/bench/Data/Mutable/Quicksort.hs b/bench/Bench/Data/Array/Mutable/Quicksort.hs similarity index 87% rename from bench/Data/Mutable/Quicksort.hs rename to bench/Bench/Data/Array/Mutable/Quicksort.hs index 0cad43b4..8407db65 100644 --- a/bench/Data/Mutable/Quicksort.hs +++ b/bench/Bench/Data/Array/Mutable/Quicksort.hs @@ -1,11 +1,11 @@ {-# LANGUAGE NumericUnderscores #-} -module Data.Mutable.Quicksort (benchmarks) where +module Bench.Data.Array.Mutable.Quicksort (benchmarks) where import Control.DeepSeq (force) import Control.Exception (evaluate) +import Data.Array.Mutable.Quicksort (quicksortUsingArray, quicksortUsingList) import Data.List (sort) -import Simple.Quicksort (quicksortUsingArray, quicksortUsingList) import System.Random import Test.Tasty.Bench diff --git a/bench/Data/Mutable/HashMap.hs b/bench/Bench/Data/HashMap/Mutable.hs similarity index 99% rename from bench/Data/Mutable/HashMap.hs rename to bench/Bench/Data/HashMap/Mutable.hs index b3e914b4..7a99985d 100644 --- a/bench/Data/Mutable/HashMap.hs +++ b/bench/Bench/Data/HashMap/Mutable.hs @@ -11,7 +11,7 @@ {-# LANGUAGE StandaloneDeriving #-} {-# LANGUAGE TupleSections #-} -module Data.Mutable.HashMap (benchmarks) where +module Bench.Data.HashMap.Mutable (benchmarks) where import Control.DeepSeq (NFData (..), deepseq, force) import qualified Control.Monad.Random as Random diff --git a/bench/Main.hs b/bench/Main.hs index b3bec2a2..f31d0d01 100644 --- a/bench/Main.hs +++ b/bench/Main.hs @@ -1,14 +1,14 @@ module Main where -import qualified Data.Mutable.Array as Array -import qualified Data.Mutable.HashMap as HashMap -import qualified Data.Mutable.Quicksort as Quicksort +import qualified Bench.Data.Array.Mutable as Array +import qualified Bench.Data.Array.Mutable.Quicksort as Quicksort +import qualified Bench.Data.HashMap.Mutable as HashMap import Test.Tasty.Bench (defaultMain) main :: IO () main = do defaultMain [ Array.benchmarks, - HashMap.benchmarks, - Quicksort.benchmarks + Quicksort.benchmarks, + HashMap.benchmarks ] diff --git a/examples/Simple/Quicksort.hs b/examples/Data/Array/Mutable/Quicksort.hs similarity index 98% rename from examples/Simple/Quicksort.hs rename to examples/Data/Array/Mutable/Quicksort.hs index 14ce1929..22d06e19 100644 --- a/examples/Simple/Quicksort.hs +++ b/examples/Data/Array/Mutable/Quicksort.hs @@ -6,7 +6,7 @@ -- {-# OPTIONS_GHC -ddump-simpl -ddump-to-file -dsuppress-all -dsuppress-uniques #-} -- | This module implements quicksort with mutable arrays from linear-base -module Simple.Quicksort where +module Data.Array.Mutable.Quicksort where import Data.Array.Mutable.Linear (Array) import qualified Data.Array.Mutable.Linear as Array diff --git a/examples/Simple/TopSort.hs b/examples/Data/HashMap/Mutable/TopSort.hs similarity index 98% rename from examples/Simple/TopSort.hs rename to examples/Data/HashMap/Mutable/TopSort.hs index a6104b63..ab861167 100644 --- a/examples/Simple/TopSort.hs +++ b/examples/Data/HashMap/Mutable/TopSort.hs @@ -5,7 +5,7 @@ {-# OPTIONS_GHC -Wno-name-shadowing #-} {-# OPTIONS_GHC -Wno-unused-matches #-} -module Simple.TopSort where +module Data.HashMap.Mutable.TopSort where import Data.Bifunctor.Linear (second) import qualified Data.Functor.Linear as Data diff --git a/examples/README.md b/examples/README.md index 776c75fa..3e6e99fd 100644 --- a/examples/README.md +++ b/examples/README.md @@ -1,10 +1,12 @@ # Examples + * `Data` + * These are examples of using the pure linear interface of mutable + data structures provided by linear base. * `Simple` * These are tutorial level examples for understanding linear types and using bread-and-butter tools in linear base. * Recommended order: `Pure`, `FileIO`. * `Foreign` * These are examples of explicitly allocating off the GC heap's - memory and on the system heap's memory - + memory and on the system heap's memory. diff --git a/linear-base.cabal b/linear-base.cabal index 35d60254..e57d013b 100644 --- a/linear-base.cabal +++ b/linear-base.cabal @@ -153,8 +153,8 @@ library examples Foreign.Heap Simple.FileIO Simple.Pure - Simple.Quicksort - Simple.TopSort + Data.Array.Mutable.Quicksort + Data.HashMap.Mutable.TopSort build-depends: base, linear-base, @@ -169,12 +169,12 @@ test-suite test main-is: Main.hs hs-source-dirs: test other-modules: - Test.Data.Destination - Test.Data.Mutable.Array - Test.Data.Mutable.Vector - Test.Data.Mutable.HashMap - Test.Data.Mutable.Set - Test.Data.Polarized + Test.Data.Array.Destination + Test.Data.Array.Mutable + Test.Data.Vector.Mutable + Test.Data.HashMap.Mutable + Test.Data.Set.Mutable + Test.Data.Array.Polarized Test.Data.Functor.Linear Test.Data.V Test.Data.Replicator @@ -200,7 +200,7 @@ test-suite test-examples hs-source-dirs: test-examples other-modules: Test.Foreign - Test.Simple.Quicksort + Test.Data.Array.Mutable.Quicksort default-language: Haskell2010 build-depends: base, @@ -217,9 +217,9 @@ benchmark bench main-is: Main.hs hs-source-dirs: bench other-modules: - Data.Mutable.HashMap - Data.Mutable.Array - Data.Mutable.Quicksort + Bench.Data.HashMap.Mutable + Bench.Data.Array.Mutable + Bench.Data.Array.Mutable.Quicksort default-language: Haskell2010 build-depends: base, diff --git a/test-examples/Main.hs b/test-examples/Main.hs index 02525f85..4b123604 100644 --- a/test-examples/Main.hs +++ b/test-examples/Main.hs @@ -1,7 +1,7 @@ module Main where +import Test.Data.Array.Mutable.Quicksort (quicksortTests) import Test.Foreign (foreignGCTests) -import Test.Simple.Quicksort (quicksortTests) import Test.Tasty main :: IO () diff --git a/test-examples/Test/Simple/Quicksort.hs b/test-examples/Test/Data/Array/Mutable/Quicksort.hs similarity index 86% rename from test-examples/Test/Simple/Quicksort.hs rename to test-examples/Test/Data/Array/Mutable/Quicksort.hs index fa276fbb..13b3f4ac 100644 --- a/test-examples/Test/Simple/Quicksort.hs +++ b/test-examples/Test/Data/Array/Mutable/Quicksort.hs @@ -1,12 +1,12 @@ {-# LANGUAGE OverloadedStrings #-} -module Test.Simple.Quicksort (quicksortTests) where +module Test.Data.Array.Mutable.Quicksort (quicksortTests) where +import Data.Array.Mutable.Quicksort (quicksortUsingArray, quicksortUsingList) import Data.List (sort) import Hedgehog import qualified Hedgehog.Gen as Gen import qualified Hedgehog.Range as Range -import Simple.Quicksort (quicksortUsingArray, quicksortUsingList) import Test.Tasty import Test.Tasty.Hedgehog (testPropertyNamed) diff --git a/test/Main.hs b/test/Main.hs index 8741474b..e9ff6db6 100644 --- a/test/Main.hs +++ b/test/Main.hs @@ -3,15 +3,15 @@ module Main where -import Test.Data.Destination (destArrayTests) +import Test.Data.Array.Destination (destArrayTests) +import Test.Data.Array.Mutable (mutArrTests) +import Test.Data.Array.Polarized (polarizedArrayTests) import Test.Data.Functor.Linear (genericTests) -import Test.Data.Mutable.Array (mutArrTests) -import Test.Data.Mutable.HashMap (mutHMTests) -import Test.Data.Mutable.Set (mutSetTests) -import Test.Data.Mutable.Vector (mutVecTests) -import Test.Data.Polarized (polarizedArrayTests) +import Test.Data.HashMap.Mutable (mutHMTests) import Test.Data.Replicator (replicatorInspectionTests) +import Test.Data.Set.Mutable (mutSetTests) import Test.Data.V (vInspectionTests) +import Test.Data.Vector.Mutable (mutVecTests) import Test.Tasty main :: IO () diff --git a/test/Test/Data/Destination.hs b/test/Test/Data/Array/Destination.hs similarity index 97% rename from test/Test/Data/Destination.hs rename to test/Test/Data/Array/Destination.hs index be7d6587..71b832e7 100644 --- a/test/Test/Data/Destination.hs +++ b/test/Test/Data/Array/Destination.hs @@ -1,7 +1,7 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE NoImplicitPrelude #-} -module Test.Data.Destination (destArrayTests) where +module Test.Data.Array.Destination (destArrayTests) where import qualified Data.Array.Destination as DArray import qualified Data.Vector as Vector diff --git a/test/Test/Data/Mutable/Array.hs b/test/Test/Data/Array/Mutable.hs similarity index 99% rename from test/Test/Data/Mutable/Array.hs rename to test/Test/Data/Array/Mutable.hs index fe831894..560a2e33 100644 --- a/test/Test/Data/Mutable/Array.hs +++ b/test/Test/Data/Array/Mutable.hs @@ -14,7 +14,7 @@ -- Remarks: -- * We don't test for failure on out-of-bound access -- * We don't test the empty constructor because -module Test.Data.Mutable.Array +module Test.Data.Array.Mutable ( mutArrTests, ) where diff --git a/test/Test/Data/Polarized.hs b/test/Test/Data/Array/Polarized.hs similarity index 98% rename from test/Test/Data/Polarized.hs rename to test/Test/Data/Array/Polarized.hs index 836080f7..95f82ea7 100644 --- a/test/Test/Data/Polarized.hs +++ b/test/Test/Data/Array/Polarized.hs @@ -1,7 +1,7 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE NoImplicitPrelude #-} -module Test.Data.Polarized (polarizedArrayTests) where +module Test.Data.Array.Polarized (polarizedArrayTests) where import qualified Data.Array.Polarized as Polar import qualified Data.Array.Polarized.Pull as Pull diff --git a/test/Test/Data/Mutable/HashMap.hs b/test/Test/Data/HashMap/Mutable.hs similarity index 99% rename from test/Test/Data/Mutable/HashMap.hs rename to test/Test/Data/HashMap/Mutable.hs index 876cb126..06e6379d 100644 --- a/test/Test/Data/Mutable/HashMap.hs +++ b/test/Test/Data/HashMap/Mutable.hs @@ -18,7 +18,7 @@ -- * We don't test alter and hope insert and delete tests suffice -- * We don't test filterWithKey and hope the test for filter suffices -- * We don't test mapMaybe since mapMaybeWithKey is more general -module Test.Data.Mutable.HashMap +module Test.Data.HashMap.Mutable ( mutHMTests, ) where diff --git a/test/Test/Data/Mutable/Set.hs b/test/Test/Data/Set/Mutable.hs similarity index 99% rename from test/Test/Data/Mutable/Set.hs rename to test/Test/Data/Set/Mutable.hs index 8b06f009..a1b392f2 100644 --- a/test/Test/Data/Mutable/Set.hs +++ b/test/Test/Data/Set/Mutable.hs @@ -54,7 +54,7 @@ -- for more about how ADT axioms work. -- -- Remark: we are not testing @empty@ since it is trivial. -module Test.Data.Mutable.Set +module Test.Data.Set.Mutable ( mutSetTests, ) where diff --git a/test/Test/Data/Mutable/Vector.hs b/test/Test/Data/Vector/Mutable.hs similarity index 99% rename from test/Test/Data/Mutable/Vector.hs rename to test/Test/Data/Vector/Mutable.hs index e4f6530c..e3e43228 100644 --- a/test/Test/Data/Mutable/Vector.hs +++ b/test/Test/Data/Vector/Mutable.hs @@ -15,7 +15,7 @@ -- Remarks: -- * We don't test for failure on out-of-bound access -- * We don't test the empty constructor -module Test.Data.Mutable.Vector +module Test.Data.Vector.Mutable ( mutVecTests, ) where