Last active
December 27, 2015 11:49
-
-
Save vasily-kirichenko/7321686 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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: " |
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.
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
On could also add methods to the FileSet object and do it C# fluent style.
Like