Created
May 22, 2013 18:28
-
-
Save dvdsgl/5629783 to your computer and use it in GitHub Desktop.
Using F# active patterns to avoid boolean blindness.
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
let (|File|Directory|Missing|) path = | |
if Directory.Exists path then Directory | |
elif File.Exists path then File | |
else Missing | |
let cp_r source dest = | |
match source, dest with | |
| Missing, _ -> failwithf "missing file" | |
| File, File -> cp source dest | |
| File, Directory -> ... | |
| Directory, Directory -> ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment