Created
June 15, 2015 19:51
-
-
Save koenmetsu/feee45877a9ffbe08a03 to your computer and use it in GitHub Desktop.
DI F#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Muffin.Pictures.Archiver | |
open System | |
module Picture = | |
type IsOldDefinition = DateTimeOffset -> bool | |
type TimeTakenRetriever = string -> DateTimeOffset | |
type PathExistenceChecker = string -> bool | |
type PictureInfo = | |
{ | |
Taken:DateTimeOffset; | |
Path:string | |
} | |
type Picture = | |
| Picture of PictureInfo | |
let private createPicture timeTaken isOld (path:string) = | |
let taken = timeTaken path | |
if taken |> isOld | |
then Some (Picture {Taken=taken; Path=path}) | |
else None | |
let create (pathExists:PathExistenceChecker) (timeTaken:TimeTakenRetriever) (isOldDefinition:IsOldDefinition) (path:string) = | |
if pathExists path | |
then createPicture timeTaken isOldDefinition path | |
else None |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment