Closed
Description
Originally opened at CodePlex by ashtonkj
The default syntax highlighter will highlight a computation expression without a generic type parameter, but once a generic type parameter is provided then the syntax highlighter will not colour the computation expression. See the following code for example (In the default Visual Studio dark theme ceBoolBuilder is coloured blue, but ceBuilder<System.DateTimeKind> is not):
type TestCE<'T>() =
member this.ReturnFrom(value) =
if System.String.IsNullOrEmpty(value) then
None
else
let typeT = typeof<'T>
if typeT.IsEnum then
box (System.Enum.Parse(typeT, value)) |> Some
else if typeT = typeof<bool> then
box (bool.Parse(value)) |> Some
else None
let ceBuilder<'T> = TestCE<'T>()
let ceBoolBuilder = TestCE<bool>()
let exampleIncorrect = ceBuilder<System.DateTimeKind> { return! System.DateTimeKind.Local.ToString() }
let exampleCorrect = ceBoolBuilder { return! "true" }
Image
comments
coza99 wrote Sep 3, 2014 at 3:54 AM [x]
This is also true if the builder function is parameterized. Taking the case from above an exampletype TextCE<'T>(name:string) = .......... let ceBuilder<'T> name = TestCE<'T>(name)
Metadata
Metadata
Assignees
Labels
No labels