Try this:

1
2
3
4
5
6
7
8
9
10
11
12
[<DefaultAugmentation(false)>]
type Result =
  | Ok
  | TreatAsOk
  | DescribedOk of string
  | Fail
  | TreatAsFail
  | DescribedFail of string
  | SpecialCase
with
  member x.IsFail = match x with Fail | TreatAsFail | DescribedFail _ -> true | _ -> false
  member x.IsOk = match x with Ok | TreatAsOk | DescribedOk _ -> true | _ -> false
By on 2/17/2010 11:14 AM ()

Wouldn't 'AsFail' make more sense? or possibly 'IsFailure'? Think about it: you're saying, 'is it any of the failure cases?' Meanwhile, 'IsFail' quite logically identifies an explicit case from the union.

By on 2/17/2010 8:20 PM ()
1
[<DefaultAugmentation(false)>]

That is nice, thank you.

Wouldn't 'AsFail' make more sense? or possibly

'IsFailure'? Think about it: you're saying, 'is it any of the failure

cases?' Meanwhile, 'IsFail' quite logically identifies an explicit case

from the union.

It is definitely possible to use different name, but how should I know in first place about this restrictions? In F# this members not accessible and this makes things confusing. But "IsFailure" will become confusing in C# code, since here you will start to see "IsFail", "IsFailure", "IsTreatAsFail", etc members and distinguish one with exact match from something else can be difficult.

Anyway, this issue just minor irritation, but before CTP become RTM anything is possible, even irritant removal :)

By on 2/18/2010 12:48 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper