Skip to content

Commit 0b24d06

Browse files
authored
Merge pull request #471 from rbasso/stubs-error-messages
stubs: Substitute undefined by error message
2 parents d1dee53 + 24a9a13 commit 0b24d06

File tree

74 files changed

+176
-176
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+176
-176
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module Accumulate (accumulate) where
22

33
accumulate :: (a -> b) -> [a] -> [b]
4-
accumulate = undefined
4+
accumulate = error "You need to implement this function."

exercises/all-your-base/src/Base.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module Base (rebase) where
22

33
rebase :: Integral a => a -> a -> [a] -> Maybe [a]
4-
rebase inputBase outputBase inputDigits = undefined
4+
rebase inputBase outputBase inputDigits = error "You need to implement this function."

exercises/allergies/src/Allergies.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ data Allergen = Eggs
1111
deriving (Eq)
1212

1313
allergies :: Int -> [Allergen]
14-
allergies = undefined
14+
allergies = error "You need to implement this function."
1515

1616
isAllergicTo :: Allergen -> Int -> Bool
17-
isAllergicTo = undefined
17+
isAllergicTo = error "You need to implement this function."
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module Alphametics (solve) where
22

33
solve :: String -> Maybe [(Char, Int)]
4-
solve puzzle = undefined
4+
solve puzzle = error "You need to implement this function."

exercises/anagram/src/Anagram.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module Anagram (anagramsFor) where
22

33
anagramsFor :: String -> [String] -> [String]
4-
anagramsFor = undefined
4+
anagramsFor = error "You need to implement this function."

exercises/atbash-cipher/src/Atbash.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module Atbash (decode, encode) where
22

33
decode :: String -> String
4-
decode = undefined
4+
decode = error "You need to implement this function."
55

66
encode :: String -> String
7-
encode = undefined
7+
encode = error "You need to implement this function."

exercises/bank-account/src/BankAccount.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ module BankAccount
99
data BankAccount = Dummy
1010

1111
closeAccount :: BankAccount -> IO ()
12-
closeAccount = undefined
12+
closeAccount = error "You need to implement this function."
1313

1414
getBalance :: BankAccount -> IO (Maybe Integer)
15-
getBalance = undefined
15+
getBalance = error "You need to implement this function."
1616

1717
incrementBalance :: BankAccount -> Integer -> IO (Maybe Integer)
18-
incrementBalance = undefined
18+
incrementBalance = error "You need to implement this function."
1919

2020
openAccount :: IO BankAccount
21-
openAccount = undefined
21+
openAccount = error "You need to implement this function."

exercises/binary-search-tree/src/BST.hs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,25 @@ module BST
1313
data BST a = Dummy deriving (Eq, Show)
1414

1515
bstLeft :: BST a -> Maybe (BST a)
16-
bstLeft = undefined
16+
bstLeft = error "You need to implement this function."
1717

1818
bstRight :: BST a -> Maybe (BST a)
19-
bstRight = undefined
19+
bstRight = error "You need to implement this function."
2020

2121
bstValue :: BST a -> Maybe a
22-
bstValue = undefined
22+
bstValue = error "You need to implement this function."
2323

2424
empty :: BST a
25-
empty = undefined
25+
empty = error "You need to implement this function."
2626

2727
fromList :: Ord a => [a] -> BST a
28-
fromList = undefined
28+
fromList = error "You need to implement this function."
2929

3030
insert :: Ord a => a -> BST a -> BST a
31-
insert = undefined
31+
insert = error "You need to implement this function."
3232

3333
singleton :: a -> BST a
34-
singleton = undefined
34+
singleton = error "You need to implement this function."
3535

3636
toList :: BST a -> [a]
37-
toList = undefined
37+
toList = error "You need to implement this function."

exercises/binary/src/Binary.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module Binary (toDecimal) where
22

3-
toDecimal = undefined
3+
toDecimal = error "You need to implement this function."

exercises/bob/src/Bob.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module Bob (responseFor) where
22

33
responseFor :: String -> String
4-
responseFor = undefined
4+
responseFor = error "You need to implement this function."

exercises/bowling/src/Bowling.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ data BowlingError = IncompleteGame
55
deriving (Eq, Show)
66

77
score :: [Int] -> Either BowlingError Int
8-
score = undefined
8+
score = error "You need to implement this function."
99

exercises/change/src/Change.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module Change (findFewestCoins) where
22

33
findFewestCoins :: Integer -> [Integer] -> Maybe [Integer]
4-
findFewestCoins target coins = undefined
4+
findFewestCoins target coins = error "You need to implement this function."

exercises/clock/src/Clock.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ module Clock (clockHour, clockMin, fromHourMin, toString) where
33
data Clock = Dummy
44

55
clockHour :: Clock -> Int
6-
clockHour = undefined
6+
clockHour = error "You need to implement this function."
77

88
clockMin :: Clock -> Int
9-
clockMin = undefined
9+
clockMin = error "You need to implement this function."
1010

1111
fromHourMin :: Int -> Int -> Clock
12-
fromHourMin = undefined
12+
fromHourMin = error "You need to implement this function."
1313

1414
toString :: Clock -> String
15-
toString = undefined
15+
toString = error "You need to implement this function."

exercises/connect/src/Connect.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ module Connect (Mark(..), winner) where
33
data Mark = Cross | Nought deriving (Eq, Show)
44

55
winner :: [String] -> Maybe Mark
6-
winner = undefined
6+
winner = error "You need to implement this function."
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module CryptoSquare (encode) where
22

33
encode :: String -> String
4-
encode = undefined
4+
encode = error "You need to implement this function."

exercises/custom-set/src/CustomSet.hs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,40 +19,40 @@ import Prelude hiding (null)
1919
data CustomSet a = Dummy deriving (Eq, Show)
2020

2121
delete :: a -> CustomSet a -> CustomSet a
22-
delete = undefined
22+
delete = error "You need to implement this function."
2323

2424
difference :: CustomSet a -> CustomSet a -> CustomSet a
25-
difference = undefined
25+
difference = error "You need to implement this function."
2626

2727
empty :: CustomSet a
28-
empty = undefined
28+
empty = error "You need to implement this function."
2929

3030
fromList :: [a] -> CustomSet a
31-
fromList = undefined
31+
fromList = error "You need to implement this function."
3232

3333
insert :: a -> CustomSet a -> CustomSet a
34-
insert = undefined
34+
insert = error "You need to implement this function."
3535

3636
intersection :: CustomSet a -> CustomSet a -> CustomSet a
37-
intersection = undefined
37+
intersection = error "You need to implement this function."
3838

3939
isDisjointFrom :: CustomSet a -> CustomSet a -> Bool
40-
isDisjointFrom = undefined
40+
isDisjointFrom = error "You need to implement this function."
4141

4242
isSubsetOf :: CustomSet a -> CustomSet a -> Bool
43-
isSubsetOf = undefined
43+
isSubsetOf = error "You need to implement this function."
4444

4545
member :: a -> CustomSet a -> Bool
46-
member = undefined
46+
member = error "You need to implement this function."
4747

4848
null :: CustomSet a -> Bool
49-
null = undefined
49+
null = error "You need to implement this function."
5050

5151
size :: CustomSet a -> Int
52-
size = undefined
52+
size = error "You need to implement this function."
5353

5454
toList :: CustomSet a -> [a]
55-
toList = undefined
55+
toList = error "You need to implement this function."
5656

5757
union :: CustomSet a -> CustomSet a -> CustomSet a
58-
union = undefined
58+
union = error "You need to implement this function."
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
module Squares (difference, squareOfSums, sumOfSquares) where
22

33
difference :: Integral a => a -> a
4-
difference = undefined
4+
difference = error "You need to implement this function."
55

66
squareOfSums :: Integral a => a -> a
7-
squareOfSums = undefined
7+
squareOfSums = error "You need to implement this function."
88

99
sumOfSquares :: Integral a => a -> a
10-
sumOfSquares = undefined
10+
sumOfSquares = error "You need to implement this function."

exercises/dominoes/src/Dominoes.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module Dominoes (chain) where
22

33
chain :: [(Int, Int)] -> Maybe [(Int, Int)]
4-
chain dominoes = undefined
4+
chain dominoes = error "You need to implement this function."

exercises/etl/src/ETL.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ module ETL (transform) where
33
import Data.Map (Map)
44

55
transform :: Map a String -> Map Char a
6-
transform = undefined
6+
transform = error "You need to implement this function."

exercises/forth/src/Forth.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ data ForthError
2020
data ForthState = Dummy
2121

2222
empty :: ForthState
23-
empty = undefined
23+
empty = error "You need to implement this function."
2424

2525
evalText :: Text -> ForthState -> Either ForthError ForthState
26-
evalText = undefined
26+
evalText = error "You need to implement this function."
2727

2828
toList :: ForthState -> [Int]
29-
toList = undefined
29+
toList = error "You need to implement this function."

exercises/gigasecond/src/Gigasecond.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ module Gigasecond (fromDay) where
33
import Data.Time.Clock (UTCTime)
44

55
fromDay :: UTCTime -> UTCTime
6-
fromDay = undefined
6+
fromDay = error "You need to implement this function."

exercises/go-counting/src/Counting.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ data Color = Black | White deriving (Eq, Ord, Show)
1010
type Coord = (Int, Int)
1111

1212
territories :: [String] -> [(Set Coord, Maybe Color)]
13-
territories = undefined
13+
territories = error "You need to implement this function."
1414

1515
territoryFor :: [String] -> Coord -> Maybe (Set Coord, Maybe Color)
16-
territoryFor = undefined
16+
territoryFor = error "You need to implement this function."

exercises/grade-school/src/School.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ module School (School, add, empty, grade, sorted) where
33
data School = Dummy
44

55
add :: Int -> String -> School -> School
6-
add gradeNum student school = undefined
6+
add gradeNum student school = error "You need to implement this function."
77

88
empty :: School
9-
empty = undefined
9+
empty = error "You need to implement this function."
1010

1111
grade :: Int -> School -> [String]
12-
grade gradeNum school = undefined
12+
grade gradeNum school = error "You need to implement this function."
1313

1414
sorted :: School -> [(Int, [String])]
15-
sorted school = undefined
15+
sorted school = error "You need to implement this function."

exercises/grains/src/Grains.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module Grains (square, total) where
22

33
square :: Integer -> Maybe Integer
4-
square n = undefined
4+
square n = error "You need to implement this function."
55

66
total :: Integer
7-
total = undefined
7+
total = error "You need to implement this function."

exercises/hamming/src/Hamming.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module Hamming (distance) where
22

3-
distance = undefined
3+
distance = error "You need to implement this function."
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module Hexadecimal (hexToInt) where
22

3-
hexToInt = undefined
3+
hexToInt = error "You need to implement this function."

exercises/kindergarten-garden/src/Garden.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ data Plant = Clover
1414
deriving (Eq, Show)
1515

1616
defaultGarden :: String -> Map String [Plant]
17-
defaultGarden = undefined
17+
defaultGarden = error "You need to implement this function."
1818

1919
garden :: [String] -> String -> Map String [Plant]
20-
garden = undefined
20+
garden = error "You need to implement this function."
2121

2222
lookupPlants :: String -> Map String [Plant] -> [Plant]
23-
lookupPlants = undefined
23+
lookupPlants = error "You need to implement this function."
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module Series (largestProduct) where
22

33
largestProduct :: Int -> String -> Maybe Integer
4-
largestProduct = undefined
4+
largestProduct = error "You need to implement this function."

exercises/leap/src/LeapYear.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module LeapYear (isLeapYear) where
22

33
isLeapYear :: Integer -> Bool
4-
isLeapYear year = undefined
4+
isLeapYear year = error "You need to implement this function."

exercises/lens-person/src/Person.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ data Address = Address { _street :: String
3131
}
3232

3333
bornStreet :: Born -> String
34-
bornStreet = undefined
34+
bornStreet = error "You need to implement this function."
3535

3636
setCurrentStreet :: String -> Person -> Person
37-
setCurrentStreet = undefined
37+
setCurrentStreet = error "You need to implement this function."
3838

3939
setBirthMonth :: Int -> Person -> Person
40-
setBirthMonth = undefined
40+
setBirthMonth = error "You need to implement this function."
4141

4242
renameStreets :: (String -> String) -> Person -> Person
43-
renameStreets = undefined
43+
renameStreets = error "You need to implement this function."

exercises/linked-list/src/Deque.hs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ module Deque (Deque, mkDeque, pop, push, shift, unshift) where
33
data Deque a = Dummy
44

55
mkDeque :: IO (Deque a)
6-
mkDeque = undefined
6+
mkDeque = error "You need to implement this function."
77

88
pop :: Deque a -> IO (Maybe a)
9-
pop = undefined
9+
pop = error "You need to implement this function."
1010

1111
push :: Deque a -> a -> IO ()
12-
push = undefined
12+
push = error "You need to implement this function."
1313

1414
unshift :: Deque a -> a -> IO ()
15-
unshift = undefined
15+
unshift = error "You need to implement this function."
1616

1717
shift :: Deque a -> IO (Maybe a)
18-
shift = undefined
18+
shift = error "You need to implement this function."

exercises/list-ops/src/ListOps.hs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,25 @@ import Prelude hiding
1313
( length, reverse, map, filter, foldr, (++), concat )
1414

1515
foldl' :: (b -> a -> b) -> b -> [a] -> b
16-
foldl' = undefined
16+
foldl' = error "You need to implement this function."
1717

1818
foldr :: (a -> b -> b) -> b -> [a] -> b
19-
foldr = undefined
19+
foldr = error "You need to implement this function."
2020

2121
length :: [a] -> Int
22-
length = undefined
22+
length = error "You need to implement this function."
2323

2424
reverse :: [a] -> [a]
25-
reverse = undefined
25+
reverse = error "You need to implement this function."
2626

2727
map :: (a -> b) -> [a] -> [b]
28-
map = undefined
28+
map = error "You need to implement this function."
2929

3030
filter :: (a -> Bool) -> [a] -> [a]
31-
filter = undefined
31+
filter = error "You need to implement this function."
3232

3333
(++) :: [a] -> [a] -> [a]
34-
xs ++ ys = undefined
34+
xs ++ ys = error "You need to implement this function."
3535

3636
concat :: [[a]] -> [a]
37-
concat = undefined
37+
concat = error "You need to implement this function."

0 commit comments

Comments
 (0)