Skip to content

Commit a850ae5

Browse files
authored
Change whereIs signature to Maybe Path (#224)
1 parent ce387a2 commit a850ae5

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

exercises/chapter4/test/Main.purs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,11 @@ Note to reader: Delete this line to expand comment block -}
162162
suite "Exercise - whereIs" do
163163
test "locates a file"
164164
$ Assert.equal (Just ("/bin/"))
165+
$ map filename
165166
$ whereIs root "ls"
166167
test "doesn't locate a file"
167168
$ Assert.equal (Nothing)
169+
$ map filename
168170
$ whereIs root "cat"
169171

170172
{- Note to reader: Delete this line to expand comment block

exercises/chapter4/test/no-peeking/Solutions.purs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,12 @@ allSizes paths =
127127
)
128128
paths
129129

130-
whereIs :: Path -> String -> Maybe String
130+
whereIs :: Path -> String -> Maybe Path
131131
whereIs path fileName = head $ whereIs' $ allFiles path
132132
where
133-
whereIs' :: Array Path -> Array String
133+
whereIs' :: Array Path -> Array Path
134134
whereIs' paths = do
135135
path <- paths
136136
child <- ls path
137137
guard $ eq fileName $ fromMaybe "" $ last $ split (Pattern "/") $ filename child
138-
pure $ filename path
138+
pure path

0 commit comments

Comments
 (0)