Skip to content

Commit

Permalink
Remove labels from arity 1 functions
Browse files Browse the repository at this point in the history
  • Loading branch information
lpil committed May 17, 2023
1 parent 3cfdb3d commit 7d5db07
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 27 deletions.
25 changes: 11 additions & 14 deletions src/gleam/erlang/file.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ pub type FileInfo {
/// Error(Eacces)
/// ```
///
pub external fn file_info(path: String) -> Result(FileInfo, Reason) =
pub external fn file_info(String) -> Result(FileInfo, Reason) =
"gleam_erlang_ffi" "file_info"

/// Results in `FileInfo` about the given `path` on success, otherwise a
Expand Down Expand Up @@ -335,7 +335,7 @@ pub external fn file_info(path: String) -> Result(FileInfo, Reason) =
/// Error(Eacces)
/// ```
///
pub external fn link_info(path: String) -> Result(FileInfo, Reason) =
pub external fn link_info(String) -> Result(FileInfo, Reason) =
"gleam_erlang_ffi" "link_info"

/// Results in a `Bool` on success that indicates whether the given `path` has
Expand All @@ -356,7 +356,7 @@ pub external fn link_info(path: String) -> Result(FileInfo, Reason) =
/// Error(Enoent)
/// ```
///
pub fn is_directory(path path: String) -> Result(Bool, Reason) {
pub fn is_directory(path: String) -> Result(Bool, Reason) {
use FileInfo(file_type: file_type, ..) <- result.map(over: file_info(path))
file_type == Directory
}
Expand All @@ -379,7 +379,7 @@ pub fn is_directory(path path: String) -> Result(Bool, Reason) {
/// Error(Enoent)
/// ```
///
pub fn is_regular(path path: String) -> Result(Bool, Reason) {
pub fn is_regular(path: String) -> Result(Bool, Reason) {
use FileInfo(file_type: file_type, ..) <- result.map(over: file_info(path))
file_type == Regular
}
Expand All @@ -406,7 +406,7 @@ pub fn is_regular(path path: String) -> Result(Bool, Reason) {
/// Error(Eacces)
/// ```
///
pub fn file_exists(path path: String) -> Result(Bool, Reason) {
pub fn file_exists(path: String) -> Result(Bool, Reason) {
let result =
path
|> file_info
Expand Down Expand Up @@ -439,7 +439,7 @@ pub fn file_exists(path path: String) -> Result(Bool, Reason) {
/// Error(Eacces)
/// ```
///
pub fn link_exists(path path: String) -> Result(Bool, Reason) {
pub fn link_exists(path: String) -> Result(Bool, Reason) {
let result =
path
|> link_info
Expand Down Expand Up @@ -468,7 +468,7 @@ pub fn link_exists(path path: String) -> Result(Bool, Reason) {
/// Error(Enoent)
/// ```
///
pub external fn make_directory(path: String) -> Result(Nil, Reason) =
pub external fn make_directory(String) -> Result(Nil, Reason) =
"gleam_erlang_ffi" "make_directory"

/// Lists all files in a directory, except files with
Expand All @@ -487,7 +487,7 @@ pub external fn make_directory(path: String) -> Result(Nil, Reason) =
/// Error(Enotdir)
/// ```
///
pub external fn list_directory(path: String) -> Result(List(String), Reason) =
pub external fn list_directory(String) -> Result(List(String), Reason) =
"gleam_erlang_ffi" "list_directory"

/// Deletes a directory.
Expand All @@ -505,7 +505,7 @@ pub external fn list_directory(path: String) -> Result(List(String), Reason) =
/// Error(Enoent)
/// ```
///
pub external fn delete_directory(path: String) -> Result(Nil, Reason) =
pub external fn delete_directory(String) -> Result(Nil, Reason) =
"gleam_erlang_ffi" "delete_directory"

/// Deletes a file or directory recursively.
Expand All @@ -525,7 +525,7 @@ pub external fn delete_directory(path: String) -> Result(Nil, Reason) =
/// Error(Enoent)
/// ```
///
pub external fn recursive_delete(path: String) -> Result(Nil, Reason) =
pub external fn recursive_delete(String) -> Result(Nil, Reason) =
"gleam_erlang_ffi" "recursive_delete"

/// Read the contents of the given file as a String
Expand Down Expand Up @@ -636,10 +636,7 @@ pub fn write_bits(
do_write_bits(contents, path)
}

external fn do_write_bits(
contents: BitString,
path: String,
) -> Result(Nil, Reason) =
external fn do_write_bits(BitString, String) -> Result(Nil, Reason) =
"gleam_erlang_ffi" "write_file"

/// Append the given String contents to a file of the given name.
Expand Down
26 changes: 13 additions & 13 deletions test/gleam/erlang/file_test.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -62,23 +62,23 @@ pub fn label_test() {
pub fn dir_test() {
make_tmp_directory()
let path = tmp_path("missing_dir/foo")
let assert Error(file.Enoent) = file.make_directory(path: path)
let assert Error(file.Enoent) = file.is_directory(path: path)
let assert Error(file.Enoent) = file.is_regular(path: path)
let assert Ok(False) = file.file_exists(path: path)
let assert Ok(False) = file.link_exists(path: path)
let assert Error(file.Enoent) = file.make_directory(path)
let assert Error(file.Enoent) = file.is_directory(path)
let assert Error(file.Enoent) = file.is_regular(path)
let assert Ok(False) = file.file_exists(path)
let assert Ok(False) = file.link_exists(path)

let path = tmp_path("bar")
let assert Ok(Nil) = file.make_directory(path: path)
let assert Ok(True) = file.is_directory(path: path)
let assert Ok(False) = file.is_regular(path: path)
let assert Ok(True) = file.file_exists(path: path)
let assert Ok(True) = file.link_exists(path: path)
let assert Ok(Nil) = file.make_directory(path)
let assert Ok(True) = file.is_directory(path)
let assert Ok(False) = file.is_regular(path)
let assert Ok(True) = file.file_exists(path)
let assert Ok(True) = file.link_exists(path)

let nested_path = tmp_path("bar/baz")
let assert Ok(Nil) = file.make_directory(path: nested_path)
let assert Ok(Nil) = file.recursive_delete(path: path)
let assert Error(file.Enoent) = file.delete_directory(path: path)
let assert Ok(Nil) = file.make_directory(nested_path)
let assert Ok(Nil) = file.recursive_delete(path)
let assert Error(file.Enoent) = file.delete_directory(path)

delete_tmp_directory()
}
Expand Down

0 comments on commit 7d5db07

Please sign in to comment.