flix

0.78.0

AccessTime.flix

/*
 * Copyright 2026 Flix Authors
 *
 * Use of this source code is governed by the Apache 2.0 license
 * that can be found in the LICENSE.md file.
 */

///
/// Effect for reading the last access time of a file, and its functions.
///
pub mod Fs.AccessTime {

    use Fs.FileTime

    ///
    /// Effect for reading the last access time of a file.
    ///
    /// Use the `AccessTime.runWithFileTime` handler.
    ///
    pub eff AccessTime {

        ///
        /// Returns the last access time of the given file `f` in milliseconds since the epoch.
        ///
        def accessTime(f: String): Result[IoError, Int64]

    }

    ///
    /// Handles the `AccessTime` effect of the given function `f` using the `FileTime` effect.
    ///
    pub def runWithFileTime(f: Unit -> a \ ef): a \ (ef - AccessTime) + FileTime =
        run { f() } with handler AccessTime {
            def accessTime(filename, k) = k(Fs.FileTime.accessTime(filename))
        }

}