Skip to content

Add explicit args to Exercises - Part 1 #504

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Mar 12, 2017
Merged
4 changes: 2 additions & 2 deletions exercises/allergies/src/Allergies.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ data Allergen = Eggs
deriving (Eq)

allergies :: Int -> [Allergen]
allergies = error "You need to implement this function."
allergies score = error "You need to implement this function."

isAllergicTo :: Allergen -> Int -> Bool
isAllergicTo = error "You need to implement this function."
isAllergicTo allergen score = error "You need to implement this function."
4 changes: 2 additions & 2 deletions exercises/atbash-cipher/src/Atbash.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Atbash (decode, encode) where

decode :: String -> String
decode = error "You need to implement this function."
decode phrase = error "You need to implement this function."
Copy link
Contributor

@rbasso rbasso Mar 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would normally go for xs for strings, or maybe cipherText for more something more descriptive. I'm not sure.

Edit: phrase is also OK, of course.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also prefer following the convention (f or g for functions, xs ys for generic lists, etc.) and I'm happy to change.

The reason I choose phrase here instead, was to match the test suite, believing that it would be easier for the student to understand the test cases.

I followed this same approach for other exercises, trying to match the test suite terms whenever possible, but I'm happy to change them as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please feel free to keep or to change the names you chose.


encode :: String -> String
encode = error "You need to implement this function."
encode phrase = error "You need to implement this function."
6 changes: 3 additions & 3 deletions exercises/bank-account/src/BankAccount.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ module BankAccount
data BankAccount = Dummy

closeAccount :: BankAccount -> IO ()
closeAccount = error "You need to implement this function."
closeAccount account = error "You need to implement this function."

getBalance :: BankAccount -> IO (Maybe Integer)
getBalance = error "You need to implement this function."
getBalance account = error "You need to implement this function."

incrementBalance :: BankAccount -> Integer -> IO (Maybe Integer)
incrementBalance = error "You need to implement this function."
incrementBalance account amount = error "You need to implement this function."

openAccount :: IO BankAccount
openAccount = error "You need to implement this function."
14 changes: 7 additions & 7 deletions exercises/binary-search-tree/src/BST.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,25 @@ module BST
data BST a = Dummy deriving (Eq, Show)

bstLeft :: BST a -> Maybe (BST a)
bstLeft = error "You need to implement this function."
bstLeft tree = error "You need to implement this function."

bstRight :: BST a -> Maybe (BST a)
bstRight = error "You need to implement this function."
bstRight tree = error "You need to implement this function."

bstValue :: BST a -> Maybe a
bstValue = error "You need to implement this function."
bstValue tree = error "You need to implement this function."

empty :: BST a
empty = error "You need to implement this function."

fromList :: Ord a => [a] -> BST a
fromList = error "You need to implement this function."
fromList xs = error "You need to implement this function."

insert :: Ord a => a -> BST a -> BST a
insert = error "You need to implement this function."
insert x tree = error "You need to implement this function."

singleton :: a -> BST a
singleton = error "You need to implement this function."
singleton x = error "You need to implement this function."

toList :: BST a -> [a]
toList = error "You need to implement this function."
toList tree = error "You need to implement this function."
2 changes: 1 addition & 1 deletion exercises/bowling/src/Bowling.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ data BowlingError = IncompleteGame
deriving (Eq, Show)

score :: [Int] -> Either BowlingError Int
score = error "You need to implement this function."
score rolls = error "You need to implement this function."

8 changes: 4 additions & 4 deletions exercises/clock/src/Clock.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ module Clock (clockHour, clockMin, fromHourMin, toString) where
data Clock = Dummy

clockHour :: Clock -> Int
clockHour = error "You need to implement this function."
clockHour clock = error "You need to implement this function."

clockMin :: Clock -> Int
clockMin = error "You need to implement this function."
clockMin clock = error "You need to implement this function."

fromHourMin :: Int -> Int -> Clock
fromHourMin = error "You need to implement this function."
fromHourMin hour min = error "You need to implement this function."

toString :: Clock -> String
toString = error "You need to implement this function."
toString clock = error "You need to implement this function."
2 changes: 1 addition & 1 deletion exercises/connect/src/Connect.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ module Connect (Mark(..), winner) where
data Mark = Cross | Nought deriving (Eq, Show)

winner :: [String] -> Maybe Mark
winner = error "You need to implement this function."
winner board = error "You need to implement this function."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

board is certainly more descriptive than xss. 👍

2 changes: 1 addition & 1 deletion exercises/crypto-square/src/CryptoSquare.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module CryptoSquare (encode) where

encode :: String -> String
encode = error "You need to implement this function."
encode xs = error "You need to implement this function."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry that I know I'm contradicting #504 (comment) here, but it seemed a bit inconsistent here to use xs but phrase in atbash-cipher?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree!

24 changes: 12 additions & 12 deletions exercises/custom-set/src/CustomSet.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,40 +19,40 @@ import Prelude hiding (null)
data CustomSet a = Dummy deriving (Eq, Show)

delete :: a -> CustomSet a -> CustomSet a
delete = error "You need to implement this function."
delete x set = error "You need to implement this function."

difference :: CustomSet a -> CustomSet a -> CustomSet a
difference = error "You need to implement this function."
difference setA setB = error "You need to implement this function."

empty :: CustomSet a
empty = error "You need to implement this function."

fromList :: [a] -> CustomSet a
fromList = error "You need to implement this function."
fromList xs = error "You need to implement this function."

insert :: a -> CustomSet a -> CustomSet a
insert = error "You need to implement this function."
insert x set = error "You need to implement this function."

intersection :: CustomSet a -> CustomSet a -> CustomSet a
intersection = error "You need to implement this function."
intersection setA setB = error "You need to implement this function."

isDisjointFrom :: CustomSet a -> CustomSet a -> Bool
isDisjointFrom = error "You need to implement this function."
isDisjointFrom setA setB = error "You need to implement this function."

isSubsetOf :: CustomSet a -> CustomSet a -> Bool
isSubsetOf = error "You need to implement this function."
isSubsetOf setA setB = error "You need to implement this function."

member :: a -> CustomSet a -> Bool
member = error "You need to implement this function."
member x set = error "You need to implement this function."

null :: CustomSet a -> Bool
null = error "You need to implement this function."
null set = error "You need to implement this function."

size :: CustomSet a -> Int
size = error "You need to implement this function."
size set = error "You need to implement this function."

toList :: CustomSet a -> [a]
toList = error "You need to implement this function."
toList set = error "You need to implement this function."

union :: CustomSet a -> CustomSet a -> CustomSet a
union = error "You need to implement this function."
union setA setB = error "You need to implement this function."
6 changes: 3 additions & 3 deletions exercises/difference-of-squares/src/Squares.hs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module Squares (difference, squareOfSums, sumOfSquares) where

difference :: Integral a => a -> a
difference = error "You need to implement this function."
difference n = error "You need to implement this function."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

n fits perfectly!


squareOfSums :: Integral a => a -> a
squareOfSums = error "You need to implement this function."
squareOfSums n = error "You need to implement this function."

sumOfSquares :: Integral a => a -> a
sumOfSquares = error "You need to implement this function."
sumOfSquares n = error "You need to implement this function."
2 changes: 1 addition & 1 deletion exercises/etl/src/ETL.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ module ETL (transform) where
import Data.Map (Map)

transform :: Map a String -> Map Char a
transform = error "You need to implement this function."
transform legacyData = error "You need to implement this function."
4 changes: 2 additions & 2 deletions exercises/forth/src/Forth.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ empty :: ForthState
empty = error "You need to implement this function."

evalText :: Text -> ForthState -> Either ForthError ForthState
evalText = error "You need to implement this function."
evalText text stack = error "You need to implement this function."

toList :: ForthState -> [Int]
toList = error "You need to implement this function."
toList stack = error "You need to implement this function."
4 changes: 2 additions & 2 deletions exercises/go-counting/src/Counting.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ data Color = Black | White deriving (Eq, Ord, Show)
type Coord = (Int, Int)

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

territoryFor :: [String] -> Coord -> Maybe (Set Coord, Maybe Color)
territoryFor = error "You need to implement this function."
territoryFor board coord = error "You need to implement this function."
6 changes: 3 additions & 3 deletions exercises/kindergarten-garden/src/Garden.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ data Plant = Clover
deriving (Eq, Show)

defaultGarden :: String -> Map String [Plant]
defaultGarden = error "You need to implement this function."
defaultGarden plants = error "You need to implement this function."

garden :: [String] -> String -> Map String [Plant]
garden = error "You need to implement this function."
garden students plants = error "You need to implement this function."

lookupPlants :: String -> Map String [Plant] -> [Plant]
lookupPlants = error "You need to implement this function."
lookupPlants student garden = error "You need to implement this function."
2 changes: 1 addition & 1 deletion exercises/largest-series-product/src/Series.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Series (largestProduct) where

largestProduct :: Int -> String -> Maybe Integer
largestProduct = error "You need to implement this function."
largestProduct series digits = error "You need to implement this function."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

series seems confusing to me since an integer is not really a series. It is the size of the seires we are considering within the digits. I would think either size or span.

8 changes: 4 additions & 4 deletions exercises/lens-person/src/Person.hs
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ data Address = Address { _street :: String
}

bornStreet :: Born -> String
bornStreet = error "You need to implement this function."
bornStreet born = error "You need to implement this function."

setCurrentStreet :: String -> Person -> Person
setCurrentStreet = error "You need to implement this function."
setCurrentStreet street person = error "You need to implement this function."

setBirthMonth :: Int -> Person -> Person
setBirthMonth = error "You need to implement this function."
setBirthMonth month person = error "You need to implement this function."

renameStreets :: (String -> String) -> Person -> Person
renameStreets = error "You need to implement this function."
renameStreets f person = error "You need to implement this function."