diff --git a/src/Arithmetic.hs b/src/Arithmetic.hs index a9c0e6d..98020c9 100644 --- a/src/Arithmetic.hs +++ b/src/Arithmetic.hs @@ -1,4 +1,16 @@ -module Arithmetic where +module Arithmetic + ( isPrime, + myGCD, + coprime, + totient, + primeFactors, + primeFactorsMult, + primesR, + goldbach, + goldbachList, + multiplicativeInverse, + ) +where import Control.Arrow ((&&&)) import qualified Control.Monad as M diff --git a/src/BinaryTrees.hs b/src/BinaryTrees.hs index 838ef51..96d6a44 100644 --- a/src/BinaryTrees.hs +++ b/src/BinaryTrees.hs @@ -1,4 +1,4 @@ -module BinaryTrees where +module BinaryTrees (cbalTree, symmetric, construct, symCbalTrees, hbalTree) where import BinaryTree (Tree (..)) diff --git a/src/BinaryTrees2.hs b/src/BinaryTrees2.hs index 33418b8..cb9ae43 100644 --- a/src/BinaryTrees2.hs +++ b/src/BinaryTrees2.hs @@ -1,6 +1,22 @@ {-# OPTIONS -Wno-incomplete-uni-patterns -Wno-incomplete-patterns #-} -module BinaryTrees2 where +module BinaryTrees2 + ( countLeaves, + leaves, + internals, + atLevel, + completeBinaryTree, + layout, + layout2, + stringToTree, + treeToString, + treeToPreorder, + treeToInorder, + preInTree, + tree2ds, + ds2tree, + ) +where import BinaryTree (Tree (..)) import Control.Applicative ((<|>)) diff --git a/src/Lists.hs b/src/Lists.hs index 2b42c28..e89287b 100644 --- a/src/Lists.hs +++ b/src/Lists.hs @@ -3,7 +3,20 @@ {-# OPTIONS -Wno-incomplete-patterns #-} -module Lists where +module Lists + ( NestedList (..), + myLast, + myButLast, + elementAt, + myLength, + myReverse, + isPalindrome, + flatten, + compress, + pack, + encode, + ) +where import Control.Arrow ((&&&)) import Control.Monad ((<=<)) diff --git a/src/Lists2.hs b/src/Lists2.hs index 0aafb7a..56f1e4b 100644 --- a/src/Lists2.hs +++ b/src/Lists2.hs @@ -2,7 +2,18 @@ {-# OPTIONS -Wno-incomplete-uni-patterns #-} -module Lists2 where +module Lists2 + ( encodeModified, + decodeModified, + dupli, + repli, + dropEvery, + split, + slice, + rotate, + removeAt, + ) +where import qualified Control.Monad as M import qualified Data.List as L diff --git a/src/Lists3.hs b/src/Lists3.hs index 9185120..40f4149 100644 --- a/src/Lists3.hs +++ b/src/Lists3.hs @@ -1,6 +1,22 @@ {-# OPTIONS -Wno-incomplete-uni-patterns #-} -module Lists3 where +module Lists3 + ( insertAt, + range, + rndSelect, + diffSelect, + rndPerm', + rndPerm, + combinations, + group3, + group, + lsort, + lfsort, + fibonacci, + mmult, + fibonacci', + ) +where import qualified Control.Monad as M import Data.Array.IO (IOArray) diff --git a/src/Logic.hs b/src/Logic.hs index 969811c..1c4fdf7 100644 --- a/src/Logic.hs +++ b/src/Logic.hs @@ -1,7 +1,20 @@ {-# LANGUAGE DerivingStrategies #-} {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} -module Logic where +module Logic + ( and', + or', + nand', + nor', + xor', + impl', + equ', + table, + tablen, + gray, + huffman, + ) +where import qualified Control.Monad as M import qualified Data.Bifunctor as Bf diff --git a/src/Misc.hs b/src/Misc.hs index 5514e50..204c1ca 100644 --- a/src/Misc.hs +++ b/src/Misc.hs @@ -1,4 +1,4 @@ -module Misc where +module Misc (queens, knightsTour, knightsTo, closedKnights) where import qualified Control.Monad as M import qualified Data.Ix as Ix diff --git a/src/Monads.hs b/src/Monads.hs index b3a20a4..b56b724 100644 --- a/src/Monads.hs +++ b/src/Monads.hs @@ -1,6 +1,13 @@ {-# LANGUAGE DerivingStrategies #-} -module Monads where +module Monads + ( Operator (..), + Element (..), + randomWalkPaths, + collatz, + calculatePostfix, + ) +where import qualified Control.Monad as M import qualified Control.Monad.Identity as Id diff --git a/src/MultiwayTrees.hs b/src/MultiwayTrees.hs index 4b364d4..4648640 100644 --- a/src/MultiwayTrees.hs +++ b/src/MultiwayTrees.hs @@ -1,6 +1,16 @@ {-# LANGUAGE DerivingStrategies #-} -module MultiwayTrees where +module MultiwayTrees + ( Tree (..), + nnodes, + stringToTree, + treeToString, + ipl, + bottomUp, + treeToLisp, + lispToTree, + ) +where import Control.Applicative ((<|>)) import qualified Control.Applicative as A @@ -12,43 +22,6 @@ import qualified Parser as P data Tree a = Node a [Tree a] deriving stock (Eq, Show) -tree4 :: Tree Char -tree4 = Node 'b' [Node 'd' [], Node 'e' []] - -tree5 :: Tree Char -tree5 = - Node - 'a' - [ Node - 'f' - [ Node 'g' [] - ], - Node 'c' [], - Node - 'b' - [ Node 'd' [], - Node 'e' [] - ] - ] - -{- -tree5: - ┌──┐ - ┌─────────┤a ├────────┐ - │ └─┬┘ │ - │ │ │ - │ │ │ -┌┴─┐ ┌─┴┐ ┌┴─┐ -│f │ │c │ ┌────┤b ├─────┐ -└┬─┘ └──┘ │ └──┘ │ - │ │ │ - │ │ │ -┌┴─┐ ┌─┴┐ ┌┴─┐ -│g │ │d │ │e │ -└──┘ └──┘ └──┘ - --} - -- Problem 70B: (*) Check whether a given term represents a multiway tree. -- ANSWER: Creating an invalid tree is not possible in Haskell. diff --git a/src/Parser.hs b/src/Parser.hs index 5564d67..fe184f0 100644 --- a/src/Parser.hs +++ b/src/Parser.hs @@ -3,7 +3,7 @@ {-# OPTIONS -Wno-incomplete-patterns #-} -module Parser where +module Parser (Parser (..), parse, letter, open, close, comma, space) where import Control.Applicative (Alternative, empty, (<|>)) import qualified Control.Applicative as A diff --git a/test/MonadsSpec.hs b/test/MonadsSpec.hs index 329f6eb..18e70b1 100644 --- a/test/MonadsSpec.hs +++ b/test/MonadsSpec.hs @@ -1,7 +1,5 @@ module MonadsSpec (spec) where --- import Debug.Trace - import qualified Control.Monad as M import qualified Data.Char as C import Monads diff --git a/test/MultiwayTreesSpec.hs b/test/MultiwayTreesSpec.hs index 31741ab..33b05d3 100644 --- a/test/MultiwayTreesSpec.hs +++ b/test/MultiwayTreesSpec.hs @@ -11,6 +11,43 @@ import Test.Hspec import Test.Hspec.QuickCheck import Test.QuickCheck +tree4 :: Tree Char +tree4 = Node 'b' [Node 'd' [], Node 'e' []] + +tree5 :: Tree Char +tree5 = + Node + 'a' + [ Node + 'f' + [ Node 'g' [] + ], + Node 'c' [], + Node + 'b' + [ Node 'd' [], + Node 'e' [] + ] + ] + +{- +tree5: + ┌──┐ + ┌─────────┤a ├────────┐ + │ └─┬┘ │ + │ │ │ + │ │ │ +┌┴─┐ ┌─┴┐ ┌┴─┐ +│f │ │c │ ┌────┤b ├─────┐ +└┬─┘ └──┘ │ └──┘ │ + │ │ │ + │ │ │ +┌┴─┐ ┌─┴┐ ┌┴─┐ +│g │ │d │ │e │ +└──┘ └──┘ └──┘ + +-} + t1 :: Tree Char t1 = Node