Skip to content

Instantly share code, notes, and snippets.

@koenmetsu
Created June 15, 2015 19:51
Show Gist options
  • Save koenmetsu/feee45877a9ffbe08a03 to your computer and use it in GitHub Desktop.
Save koenmetsu/feee45877a9ffbe08a03 to your computer and use it in GitHub Desktop.
DI F#
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