Skip to content

Instantly share code, notes, and snippets.

@vasily-kirichenko
Last active December 27, 2015 11:49
Show Gist options
  • Save vasily-kirichenko/7321686 to your computer and use it in GitHub Desktop.
Save vasily-kirichenko/7321686 to your computer and use it in GitHub Desktop.
type FileSetBuilder() =
member x.Delay f = f
member x.Run f = f() |> Scan
member x.Yield (()) = { Include "" with Includes = [] }
[<CustomOperation ("take", MaintainsVariableSpace = true)>]
member x.Take (fs, pattern: string) = fs ++ pattern
[<CustomOperation ("notTake", MaintainsVariableSpace = true)>]
member x.NotTake (fs: FileIncludes, pattern: string) = fs -- pattern
let files = FileSetBuilder()
Target "Build" {
files {
take "**\bin\**\*Tests.dll"
take "**\bin2\**\*Tests.dll"
take "**\binaries\**\*"
notTake "**\bin2\Special*\*"
take "**\binaries2\**\*"
}
|> MSBuildDebug @".\out1" "Build"
|> Log "AppBuild-Output: "
}
// old syntax
Target "Build" <| fun _ ->
!+ "**\bin\**\*Tests.dll"
++ "**\bin2\**\*Tests.dll"
++ "**\binaries\**\*"
-- "**\bin2\Special*\*"
++ "**\binaries2\**\*"
|> Scan
|> MSBuildDebug @".\out1" "Build"
|> Log "AppBuild-Output: "
@ilkerde
Copy link

ilkerde commented Nov 5, 2013

I for one would have the least surprise when obvious names are used with the builtin function composition options (like pipe operator). I feel quite safe with the scan/include/exclude syntax. It's nice to have a more 'obvious' syntax for the beginner as well as a more 'terse' syntax for the advanced users.

@vasily-kirichenko
Copy link
Author

I'm rather sceptical about C# fluent style these days. However, as an option among others it could be ideal for using by C# devs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment