Skip to content

Commit

Permalink
Make exports explicit
Browse files Browse the repository at this point in the history
  • Loading branch information
Abhijit Sarkar committed Jan 2, 2024
1 parent 84b5275 commit 5a65fe4
Show file tree
Hide file tree
Showing 13 changed files with 146 additions and 50 deletions.
14 changes: 13 additions & 1 deletion src/Arithmetic.hs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/BinaryTrees.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module BinaryTrees where
module BinaryTrees (cbalTree, symmetric, construct, symCbalTrees, hbalTree) where

import BinaryTree (Tree (..))

Expand Down
18 changes: 17 additions & 1 deletion src/BinaryTrees2.hs
Original file line number Diff line number Diff line change
@@ -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 ((<|>))
Expand Down
15 changes: 14 additions & 1 deletion src/Lists.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ((<=<))
Expand Down
13 changes: 12 additions & 1 deletion src/Lists2.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 17 additions & 1 deletion src/Lists3.hs
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
15 changes: 14 additions & 1 deletion src/Logic.hs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Misc.hs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
9 changes: 8 additions & 1 deletion src/Monads.hs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
49 changes: 11 additions & 38 deletions src/MultiwayTrees.hs
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion src/Parser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions test/MonadsSpec.hs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
37 changes: 37 additions & 0 deletions test/MultiwayTreesSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5a65fe4

Please sign in to comment.