{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/visualfsharp/issues/332","labels_url":"https://api.github.com/repos/Microsoft/visualfsharp/issues/332/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/visualfsharp/issues/332/comments","events_url":"https://api.github.com/repos/Microsoft/visualfsharp/issues/332/events","html_url":"https://github.com/Microsoft/visualfsharp/issues/332","id":64383263,"number":332,"title":"`[<ProjectionParameter>] ` on `for`'s sequence parameter ignored?","user":{"login":"Gitgiddy","id":8322472,"avatar_url":"https://avatars.githubusercontent.com/u/8322472?v=3","gravatar_id":"","url":"https://api.github.com/users/Gitgiddy","html_url":"https://github.com/Gitgiddy","followers_url":"https://api.github.com/users/Gitgiddy/followers","following_url":"https://api.github.com/users/Gitgiddy/following{/other_user}","gists_url":"https://api.github.com/users/Gitgiddy/gists{/gist_id}","starred_url":"https://api.github.com/users/Gitgiddy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Gitgiddy/subscriptions","organizations_url":"https://api.github.com/users/Gitgiddy/orgs","repos_url":"https://api.github.com/users/Gitgiddy/repos","events_url":"https://api.github.com/users/Gitgiddy/events{/privacy}","received_events_url":"https://api.github.com/users/Gitgiddy/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Microsoft/visualfsharp/labels/by%20design","name":"by design","color":"fbca04"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-03-25T22:04:04Z","updated_at":"2015-04-01T13:54:09Z","closed_at":"2015-04-01T03:24:56Z","body":"\r\nThe following CE builder intends to accept a Domain which has enumerable-like members and, for this situation, return a bool. But the member of the domain being checked varies. I try to parameterize the selection of the member, rather than just expecting the member directly (which changes the type).\r\n\r\nThis code type-checks as is, but it requires the full lambda as the `over` parameter to `For`.\r\n\r\n    type Domain = interface end\r\n    type Projection<'R> = \r\n        abstract member source : Table<'R>\r\n    and Table<'R> = inherit Projection<'R>\r\n    and Table<'R, 'K> = \r\n        inherit Table<('R * 'K)>\r\n        abstract member row : 'R\r\n        abstract member key : 'K\r\n\r\n    type proj<'R> = Projection<'R>\r\n    type table<'R> = Table<'R>\r\n\r\n    type Engine<'D> when 'D :> Domain = \r\n        abstract member from: 'R table * ('R proj -> 'U) -> 'U\r\n        abstract member where: ('R -> bool) * 'R proj -> 'R proj\r\n        abstract member any: ('R -> bool) * 'R proj -> bool\r\n        abstract member select: ('R -> 'S) * 'R proj -> 'S proj\r\n\r\n    type A = { ID : int; Name : string }\r\n    type B = { ID2 : int; Name2 : string }\r\n    type MyDomain =\r\n        inherit Domain\r\n        abstract member As : A table\r\n        abstract member Bs : B table\r\n\r\n    type CommandBuilder<'D> when 'D :> Domain () =\r\n        // [<CustomOperation(\"for\")>]  **no effect (?)** \r\n        member __.For ([<ProjectionParameter>] over : ('D -> 'R table), expr : ('R proj -> _)) =       // [<ProjectionParameter>] is ignored\r\n            (fun (engine : Engine<'D>, domain : 'D) -> engine.from(over(domain), expr))\r\n        member __.Yield x = x\r\n\r\n        [<CustomOperation(\"select\")>]\r\n        member __.Select (over : (Engine<'D> * 'D -> 'R proj), [<ProjectionParameter>] mapping : ('R -> _)) = \r\n            (fun (engine : Engine<'D>, domain : 'D) -> engine.select(mapping, over(engine, domain)))\r\n\r\n        [<CustomOperation(\"where\", MaintainsVariableSpace = true)>]\r\n        member __.Where (over : (Engine<'D> * 'D -> 'R proj), [<ProjectionParameter>] byPredicate : ('R -> bool)) = \r\n            (fun (engine : Engine<'D>, domain : 'D) -> engine.where(byPredicate, over(engine, domain)))\r\n\r\n        [<CustomOperation(\"any\", MaintainsVariableSpace = true)>]\r\n        member __.Any (over : (Engine<'D> * 'D -> 'R proj), [<ProjectionParameter>] byPredicate : ('R -> bool)) = \r\n            (fun (engine : Engine<'D>, domain : 'D) -> engine.any(byPredicate, over(engine, domain)))\r\n\r\n        member __.Quote() = ()\r\n        member __.Run(q) = q\r\n\r\n    let command = new CommandBuilder<MyDomain>()\r\n\r\n    let invariant1 =\r\n        command {\r\n            for a in (fun _d -> _d.As) do  // should be `for a in d.As do`\r\n            any (a.Name = \"disallowed value\")\r\n        }\r\n\r\n    let invariant2 =\r\n        command {\r\n            for b in (fun _d -> _d.Bs) do  // should be `for a in d.Bs do`\r\n            any (b.Name2 = \"disallowed value\")\r\n        }\r\n\r\n    let domainInvariants = [ invariant1; invariant2 ]"},"comment":{"url":"https://api.github.com/repos/Microsoft/visualfsharp/issues/comments/88488408","html_url":"https://github.com/Microsoft/visualfsharp/issues/332#issuecomment-88488408","issue_url":"https://api.github.com/repos/Microsoft/visualfsharp/issues/332","id":88488408,"user":{"login":"Gitgiddy","id":8322472,"avatar_url":"https://avatars.githubusercontent.com/u/8322472?v=3","gravatar_id":"","url":"https://api.github.com/users/Gitgiddy","html_url":"https://github.com/Gitgiddy","followers_url":"https://api.github.com/users/Gitgiddy/followers","following_url":"https://api.github.com/users/Gitgiddy/following{/other_user}","gists_url":"https://api.github.com/users/Gitgiddy/gists{/gist_id}","starred_url":"https://api.github.com/users/Gitgiddy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Gitgiddy/subscriptions","organizations_url":"https://api.github.com/users/Gitgiddy/orgs","repos_url":"https://api.github.com/users/Gitgiddy/repos","events_url":"https://api.github.com/users/Gitgiddy/events{/privacy}","received_events_url":"https://api.github.com/users/Gitgiddy/received_events","type":"User","site_admin":false},"created_at":"2015-04-01T13:54:09Z","updated_at":"2015-04-01T13:54:09Z","body":"OK, I added this as a feature request too. I updated the original post with a much better code sample illustrating the issue."}}