Hello everyone,

I do not understand what the compiler is unhappy about and how to fix it:

let myExpression= <@ fun a - > a @>

Error 1 Value restriction. Type inference has inferred the signature val myExpression : Quotations.Expr<('_a -> '_a)> Either define 'myExpression' as a simple data term, make it a function, or add a type constraint to instantiate the type parameters.

Value restriction is actually independent of quotations, though it seems some extra constraints are in place in this case. It's basically a limitation of type inference in the presence of side-effects.

1
let g = id >> id

Produces a similar error. You have typically a few ways of getting around the value restriction, as the error message explains. ("Either define...").It's kind of complex and some of it I don't reallly understand myself yet, so I'll put a link here ;)[link:www.strangelights.com]

By on 4/27/2009 12:28 AM ()

I think you want e.g.

1
2
3
4
 

let f<'a> = <@ (fun (x:'a) -> x) @>
By on 4/26/2009 1:45 PM ()

exactly, so types are mandatory?

By on 4/26/2009 1:48 PM ()
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