Skip to content
This repository was archived by the owner on Mar 22, 2021. It is now read-only.

Commit 86b25f3

Browse files
committed
Sort functions alphabetically
Done for consistency and ease of navigation.
1 parent 3f61cc5 commit 86b25f3

2 files changed

Lines changed: 123 additions & 106 deletions

File tree

README.md

Lines changed: 94 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -257,39 +257,41 @@ Returns:
257257

258258
### Path Manipulation Functions
259259

260-
This library includes wrappers around the following functions from the [filepath](https://hackage.haskell.org/package/filepath-1.4.2.1/docs/System-FilePath.html) library for the current platform (POSIX or Windows). All examples below are for [POSIX systems](https://hackage.haskell.org/package/filepath-1.4.2.1/docs/System-FilePath-Posix.html).
260+
This library includes wrappers around the following functions from
261+
the [filepath] library for the current platform (POSIX or
262+
Windows). All examples below are for [POSIX
263+
systems].
261264

262-
#### take_directory
265+
#### drop_extension
263266

264-
`take_directory(filepath)`
267+
`drop_extension(filepath)`
265268

266-
Get the directory name, move up one level.
269+
Remove last extension, and the `.` preceding it.
267270

268271
```lua
269-
takeDirectory("/foo/bar/baz") == "/foo/bar"
270-
takeDirectory("/foo/bar/baz/") == "/foo/bar/baz"
272+
dropExtension("/directory/path.ext") == "/directory/path"
271273
```
272274

273275
Parameters:
274276

275277
`filepath`
276-
: path path
278+
: path
277279

278280
Returns:
279281

280-
- The modified filepath.
282+
- The modified filepath without extension.
281283

282-
This function wraps [System.FilePath.takeDirectory](https://hackage.haskell.org/package/filepath-1.4.2.1/docs/System-FilePath-Posix.html#v:takeDirectory).
284+
This function wraps [System.FilePath.dropExtension].
283285

284-
#### take_filename
286+
#### has_extension
285287

286-
`take_filename(filepath)`
288+
`has_extensions(filepath)`
287289

288-
Get the file name.
290+
Does the given filename have an extension?
289291

290292
```lua
291-
takeFileName("/directory/file.ext") == "file.ext"
292-
takeFileName("test/") == ""
293+
hasExtension("/directory/path.ext") == true
294+
hasExtension("/directory/path") == false
293295
```
294296

295297
Parameters:
@@ -299,20 +301,15 @@ Parameters:
299301

300302
Returns:
301303

302-
- The file name.
303-
304-
This function wraps [System.FilePath.takeFileName](https://hackage.haskell.org/package/filepath-1.4.2.1/docs/System-FilePath-Posix.html#v:takeFileName).
304+
- `true` if `filepath` has an extension.
305305

306-
#### take_extensions
306+
This function wraps [System.FilePath.hasExtension].
307307

308-
`take_extensions(filepath)`
308+
#### is_absolute
309309

310-
Get all extensions.
310+
`is_absolute(filepath)`
311311

312-
```lua
313-
takeExtensions("/directory/path.ext") == ".ext"
314-
takeExtensions("file.tar.gz") == ".tar.gz
315-
```
312+
Is a path absolute? (same as `! is_relative(filepath)`)
316313

317314
Parameters:
318315

@@ -321,18 +318,20 @@ Parameters:
321318

322319
Returns:
323320

324-
- String of all extensions.
321+
- `true` if `filepath` is an absolute path.
325322

326-
This function wraps [System.FilePath.takeExtensions](https://hackage.haskell.org/package/filepath-1.4.2.1/docs/System-FilePath-Posix.html#v:takeExtensions).
323+
This function wraps [System.FilePath.isAbsolute].
327324

328-
#### drop_extension
325+
#### is_relative
329326

330-
`drop_extension(filepath)`
327+
`ìs_relative(filepath)`
331328

332-
Remove last extension, and the `.` preceding it.
329+
Is a path relative, or is it fixed to the root?
333330

334331
```lua
335-
dropExtension("/directory/path.ext") == "/directory/path"
332+
isRelative("test/path") == true
333+
isRelative("/test") == false
334+
isRelative("/") == false
336335
```
337336

338337
Parameters:
@@ -342,31 +341,47 @@ Parameters:
342341

343342
Returns:
344343

345-
- The modified filepath without extension.
344+
- `true` if `filepath` is a relative path.
346345

347-
This function wraps [System.FilePath.dropExtension](https://hackage.haskell.org/package/filepath-1.4.2.1/docs/System-FilePath-Posix.html#v:dropExtension).
346+
This function wraps [System.FilePath.isRelative].
348347

349-
#### has_extension
348+
#### join_path
350349

351-
`has_extensions(filepath)`
350+
`join_path(filepaths)`
352351

353-
Does the given filename have an extension?
352+
Join path elements back together by the directory separator.
354353

355354
```lua
356-
hasExtension("/directory/path.ext") == true
357-
hasExtension("/directory/path") == false
355+
joinPath({"/","directory/","file.ext"}) == "/directory/file.ext"
358356
```
359357

360358
Parameters:
361359

360+
`filepaths`
361+
: list of paths
362+
363+
Returns:
364+
365+
- The joined path.
366+
367+
This function wraps [System.FilePath.joinPath].
368+
369+
#### normalise
370+
371+
`normalise(filepath)`
372+
373+
Normalise a path. See examples [here][System.FilePath.normalize].
374+
375+
Parameters:
376+
362377
`filepath`
363378
: path
364379

365380
Returns:
366381

367-
- `true` if `filepath` has an extension.
382+
- The normalised path.
368383

369-
This function wraps [System.FilePath.hasExtension](https://hackage.haskell.org/package/filepath-1.4.2.1/docs/System-FilePath-Posix.html#v:hasExtension).
384+
This function wraps [System.FilePath.normalise].
370385

371386
#### split_directories
372387

@@ -389,39 +404,39 @@ Returns:
389404

390405
- A list of all directory paths.
391406

392-
This function wraps [System.FilePath.splitDirectories](https://hackage.haskell.org/package/filepath-1.4.2.1/docs/System-FilePath-Posix.html#v:splitDirectories).
407+
This function wraps [System.FilePath.splitDirectories].
393408

394-
#### join_path
409+
#### take_directory
395410

396-
`join_path(filepaths)`
411+
`take_directory(filepath)`
397412

398-
Join path elements back together by the directory separator.
413+
Get the directory name, move up one level.
399414

400415
```lua
401-
joinPath({"/","directory/","file.ext"}) == "/directory/file.ext"
416+
takeDirectory("/foo/bar/baz") == "/foo/bar"
417+
takeDirectory("/foo/bar/baz/") == "/foo/bar/baz"
402418
```
403419

404420
Parameters:
405421

406-
`filepaths`
407-
: list of paths
422+
`filepath`
423+
: path path
408424

409425
Returns:
410426

411-
- The joined path.
427+
- The modified filepath.
412428

413-
This function wraps [System.FilePath.joinPath](https://hackage.haskell.org/package/filepath-1.4.2.1/docs/System-FilePath-Posix.html#v:joinPath).
429+
This function wraps [System.FilePath.takeDirectory].
414430

415-
#### is_relative
431+
#### take_extensions
416432

417-
`ìs_relative(filepath)`
433+
`take_extensions(filepath)`
418434

419-
Is a path relative, or is it fixed to the root?
435+
Get all extensions.
420436

421437
```lua
422-
isRelative("test/path") == true
423-
isRelative("/test") == false
424-
isRelative("/") == false
438+
takeExtensions("/directory/path.ext") == ".ext"
439+
takeExtensions("file.tar.gz") == ".tar.gz
425440
```
426441

427442
Parameters:
@@ -431,32 +446,20 @@ Parameters:
431446

432447
Returns:
433448

434-
- `true` if `filepath` is a relative path.
435-
436-
This function wraps [System.FilePath.isRelative](https://hackage.haskell.org/package/filepath-1.4.2.1/docs/System-FilePath-Posix.html#v:isRelative).
437-
438-
#### is_absolute
439-
440-
`is_absolute(filepath)`
441-
442-
Is a path absolute? (same as `! is_relative(filepath)`)
443-
444-
Parameters:
445-
446-
`filepath`
447-
: path
448-
449-
Returns:
449+
- String of all extensions.
450450

451-
- `true` if `filepath` is an absolute path.
451+
This function wraps [System.FilePath.takeExtensions].
452452

453-
This function wraps [System.FilePath.isAbsolute](https://hackage.haskell.org/package/filepath-1.4.2.1/docs/System-FilePath-Posix.html#v:isAbsolute).
453+
#### take_filename
454454

455-
#### normalise
455+
`take_filename(filepath)`
456456

457-
`normalise(filepath)`
457+
Get the file name.
458458

459-
Normalise a path. See examples [here](https://hackage.haskell.org/package/filepath-1.4.2.1/docs/System-FilePath-Posix.html#v:normalise).
459+
```lua
460+
takeFileName("/directory/file.ext") == "file.ext"
461+
takeFileName("test/") == ""
462+
```
460463

461464
Parameters:
462465

@@ -465,9 +468,23 @@ Parameters:
465468

466469
Returns:
467470

468-
- The normalised path.
471+
- The file name.
469472

470-
This function wraps [System.FilePath.normalise](https://hackage.haskell.org/package/filepath-1.4.2.1/docs/System-FilePath-Posix.html#v:normalise).
473+
This function wraps [System.FilePath.takeFileName].
474+
475+
476+
[filepath]: https://hackage.haskell.org/package/filepath-1.4.2.1/docs/System-FilePath.html
477+
[POSIX systems]: https://hackage.haskell.org/package/filepath-1.4.2.1/docs/System-FilePath-Posix.html
478+
[System.FilePath.dropExtension]: https://hackage.haskell.org/package/filepath-1.4.2.1/docs/System-FilePath-Posix.html#v:dropExtension
479+
[System.FilePath.hasExtension]: https://hackage.haskell.org/package/filepath-1.4.2.1/docs/System-FilePath-Posix.html#v:hasExtension
480+
[System.FilePath.isAbsolute]: https://hackage.haskell.org/package/filepath-1.4.2.1/docs/System-FilePath-Posix.html#v:isAbsolute
481+
[System.FilePath.isRelative]: https://hackage.haskell.org/package/filepath-1.4.2.1/docs/System-FilePath-Posix.html#v:isRelative
482+
[System.FilePath.joinPath]: https://hackage.haskell.org/package/filepath-1.4.2.1/docs/System-FilePath-Posix.html#v:joinPath
483+
[System.FilePath.normalise]: https://hackage.haskell.org/package/filepath-1.4.2.1/docs/System-FilePath-Posix.html#v:normalise
484+
[System.FilePath.splitDirectories]: https://hackage.haskell.org/package/filepath-1.4.2.1/docs/System-FilePath-Posix.html#v:splitDirectories.
485+
[System.FilePath.takeDirectory]: https://hackage.haskell.org/package/filepath-1.4.2.1/docs/System-FilePath-Posix.html#v:takeDirectory
486+
[System.FilePath.takeExtensions]: https://hackage.haskell.org/package/filepath-1.4.2.1/docs/System-FilePath-Posix.html#v:takeExtensions.
487+
[System.FilePath.takeFileName]: https://hackage.haskell.org/package/filepath-1.4.2.1/docs/System-FilePath-Posix.html#v:takeFileName.
471488

472489
## License
473490

src/Foreign/Lua/Module/System.hs

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,16 @@ module Foreign.Lua.Module.System (
3535
, with_wd
3636

3737
-- * Path manipulations
38-
, take_directory
39-
, take_filename
40-
, take_extensions
41-
, split_directories
42-
, has_extension
4338
, drop_extensions
44-
, join_path
45-
, is_relative
39+
, has_extension
4640
, is_absolute
41+
, is_relative
42+
, join_path
4743
, normalise
44+
, split_directories
45+
, take_directory
46+
, take_extensions
47+
, take_filename
4848
)
4949
where
5050

@@ -234,18 +234,6 @@ with_tmpdir parentDir tmpl callback =
234234
-- Path manipulations
235235
--
236236

237-
-- | See @System.FilePath.takeDirectory@
238-
take_directory :: FilePath -> Lua FilePath
239-
take_directory fp = return (Fp.takeDirectory fp)
240-
241-
-- | See @System.FilePath.takeFilename@
242-
take_filename :: FilePath -> Lua FilePath
243-
take_filename fp = return (Fp.takeFileName fp)
244-
245-
-- | See @System.FilePath.takeExtensions@
246-
take_extensions :: FilePath -> Lua String
247-
take_extensions fp = return (Fp.takeExtensions fp)
248-
249237
-- | See @System.FilePath.dropExtension@
250238
drop_extensions :: FilePath -> Lua String
251239
drop_extensions fp = return (Fp.dropExtensions fp)
@@ -254,22 +242,34 @@ drop_extensions fp = return (Fp.dropExtensions fp)
254242
has_extension :: FilePath -> Lua Bool
255243
has_extension fp = return (Fp.hasExtension fp)
256244

257-
-- | See @System.FilePath.splitDirectories@
258-
split_directories :: FilePath -> Lua [FilePath]
259-
split_directories fp = return (Fp.splitDirectories fp)
260-
261-
-- | See @System.FilePath.joinPath@
262-
join_path :: [FilePath] -> Lua FilePath
263-
join_path fps = return (Fp.joinPath fps)
245+
-- | See @System.FilePath.isAbsolute@
246+
is_absolute :: FilePath -> Lua Bool
247+
is_absolute fp = return (Fp.isAbsolute fp)
264248

265249
-- | See @System.FilePath.isRelative@
266250
is_relative :: FilePath -> Lua Bool
267251
is_relative fp = return (Fp.isRelative fp)
268252

269-
-- | See @System.FilePath.isAbsolute@
270-
is_absolute :: FilePath -> Lua Bool
271-
is_absolute fp = return (Fp.isAbsolute fp)
253+
-- | See @System.FilePath.joinPath@
254+
join_path :: [FilePath] -> Lua FilePath
255+
join_path fps = return (Fp.joinPath fps)
272256

273257
-- | See @System.FilePath.normalise@
274258
normalise :: FilePath -> Lua FilePath
275259
normalise fp = return (Fp.normalise fp)
260+
261+
-- | See @System.FilePath.splitDirectories@
262+
split_directories :: FilePath -> Lua [FilePath]
263+
split_directories fp = return (Fp.splitDirectories fp)
264+
265+
-- | See @System.FilePath.takeDirectory@
266+
take_directory :: FilePath -> Lua FilePath
267+
take_directory fp = return (Fp.takeDirectory fp)
268+
269+
-- | See @System.FilePath.takeExtensions@
270+
take_extensions :: FilePath -> Lua String
271+
take_extensions fp = return (Fp.takeExtensions fp)
272+
273+
-- | See @System.FilePath.takeFilename@
274+
take_filename :: FilePath -> Lua FilePath
275+
take_filename fp = return (Fp.takeFileName fp)

0 commit comments

Comments
 (0)