{"action":"created","issue":{"url":"https://api.github.com/repos/freya-fs/freya/issues/189","repository_url":"https://api.github.com/repos/freya-fs/freya","labels_url":"https://api.github.com/repos/freya-fs/freya/issues/189/labels{/name}","comments_url":"https://api.github.com/repos/freya-fs/freya/issues/189/comments","events_url":"https://api.github.com/repos/freya-fs/freya/issues/189/events","html_url":"https://github.com/freya-fs/freya/issues/189","id":142647627,"number":189,"title":"[Suggestion] Combinator operators for partial application of functions wrapped in Freya computations","user":{"login":"Vidarls","id":549092,"avatar_url":"https://avatars.githubusercontent.com/u/549092?v=3","gravatar_id":"","url":"https://api.github.com/users/Vidarls","html_url":"https://github.com/Vidarls","followers_url":"https://api.github.com/users/Vidarls/followers","following_url":"https://api.github.com/users/Vidarls/following{/other_user}","gists_url":"https://api.github.com/users/Vidarls/gists{/gist_id}","starred_url":"https://api.github.com/users/Vidarls/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Vidarls/subscriptions","organizations_url":"https://api.github.com/users/Vidarls/orgs","repos_url":"https://api.github.com/users/Vidarls/repos","events_url":"https://api.github.com/users/Vidarls/events{/privacy}","received_events_url":"https://api.github.com/users/Vidarls/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2016-03-22T13:19:47Z","updated_at":"2016-04-05T09:53:46Z","closed_at":null,"body":"As I previously mentioned in #182 I've had some issues getting to grips being inside / outside Freya computations. Particularly with regards to passing around partially applied functions that requires arguments from inside a Freya computation, (and thus themselves get wrapped in a Freya computation after..)\r\n\r\nI ended up creating the some custom operators (again). \r\n\r\n(Btw, I really wish F# would support named operators, rather than just symbolic ones, would help readability a lot..)\r\n\r\nI do have a lot of holes in my functional vocabulary, so I have no idea what to actually call these but here they are:\r\n\r\n```f#\r\nlet (<!^>) f v = \r\n    freya {\r\n        let! f = f \r\n        return f v\r\n    } \r\n\r\nlet (<^!>) f v = \r\n    freya {\r\n        let! v = v\r\n        return! f v\r\n    }\r\n```\r\n\r\nThe first operator will take a function wrapped in a Freya computation, \"dereference\" it(?) and apply the given argument, returning the result wrapped in a Freya computation.\r\n\r\nExample:\r\n\r\n```f#\r\nopen Freya.Core.Operators\r\n\r\nlet myFunction with' some args = \r\n    (...)\r\n\r\nlet myValueInAFreya = \r\n    freya {\r\n        return \"some stuff\"\r\n    }\r\n\r\nlet myValueNotInAFreya = \r\n    \"some stuff\"\r\nlet myPartiallyAppliedOne = myFunction <!> myValueInAFreya\r\n// Above is now Freya<'a->'b->'c>\r\n// I want to add another arg partially applied\r\n\r\nlet myPartiallyAppliedTwo = myPartiallyAppliedOne <!^> myValueNotInAFreya\r\n// Above is now Freya<'a->'b>\r\n```\r\n\r\nIt is possible I have misunderstood something, but adding the new operator helped me quite a bit..\r\n\r\nThe scenario for the other operator is a bit more weird. I ended up creating it because using the standard `<!>` map(?) operator ended up giving med nested Freyas (`Freya<Freya<'t>>`) which I was not what I was looking for.\r\n\r\nExample:\r\n\r\n```f#\r\nlet myFunctionNotInAFreya some arg = \r\n    (...)\r\n\r\nlet myFunctionReturningAFreyaWrappedFun () = \r\n    freya {\r\n        return (fun x -> x.ToString())\r\n    }\r\n\r\n//this gives me nested Freyas:\r\n\r\nlet normalMap = myFunctionNotInAFreya <!> (myFunctionReturningAFreyaWrappedFun ())\r\n// above gives `Freya<Freya<'a->'b>>`\r\n\r\n// using my operator:\r\nlet asExpected = myFunctionNotInAFreya <^!> (myFunctionReturningAFreyaWrappedFun ())\r\n//above gives `Freya<'a->'b>`as expected.\r\n```\r\n\r\nThis may or may not be something to include as part of the core operators..\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/freya-fs/freya/issues/comments/205734965","html_url":"https://github.com/freya-fs/freya/issues/189#issuecomment-205734965","issue_url":"https://api.github.com/repos/freya-fs/freya/issues/189","id":205734965,"user":{"login":"kolektiv","id":1546,"avatar_url":"https://avatars.githubusercontent.com/u/1546?v=3","gravatar_id":"","url":"https://api.github.com/users/kolektiv","html_url":"https://github.com/kolektiv","followers_url":"https://api.github.com/users/kolektiv/followers","following_url":"https://api.github.com/users/kolektiv/following{/other_user}","gists_url":"https://api.github.com/users/kolektiv/gists{/gist_id}","starred_url":"https://api.github.com/users/kolektiv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kolektiv/subscriptions","organizations_url":"https://api.github.com/users/kolektiv/orgs","repos_url":"https://api.github.com/users/kolektiv/repos","events_url":"https://api.github.com/users/kolektiv/events{/privacy}","received_events_url":"https://api.github.com/users/kolektiv/received_events","type":"User","site_admin":false},"created_at":"2016-04-05T09:53:46Z","updated_at":"2016-04-05T09:53:46Z","body":"Sure, let me put something together :) I'll have a think on the naming!"}}