{"action":"created","issue":{"url":"https://api.github.com/repos/idris-lang/Idris-dev/issues/1969","labels_url":"https://api.github.com/repos/idris-lang/Idris-dev/issues/1969/labels{/name}","comments_url":"https://api.github.com/repos/idris-lang/Idris-dev/issues/1969/comments","events_url":"https://api.github.com/repos/idris-lang/Idris-dev/issues/1969/events","html_url":"https://github.com/idris-lang/Idris-dev/pull/1969","id":59416478,"number":1969,"title":"DSL extension: Named lambda and let","user":{"login":"chetant","id":700764,"avatar_url":"https://avatars.githubusercontent.com/u/700764?v=3","gravatar_id":"","url":"https://api.github.com/users/chetant","html_url":"https://github.com/chetant","followers_url":"https://api.github.com/users/chetant/followers","following_url":"https://api.github.com/users/chetant/following{/other_user}","gists_url":"https://api.github.com/users/chetant/gists{/gist_id}","starred_url":"https://api.github.com/users/chetant/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chetant/subscriptions","organizations_url":"https://api.github.com/users/chetant/orgs","repos_url":"https://api.github.com/users/chetant/repos","events_url":"https://api.github.com/users/chetant/events{/privacy}","received_events_url":"https://api.github.com/users/chetant/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":10,"created_at":"2015-03-01T20:44:09Z","updated_at":"2015-03-02T09:31:42Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/idris-lang/Idris-dev/pulls/1969","html_url":"https://github.com/idris-lang/Idris-dev/pull/1969","diff_url":"https://github.com/idris-lang/Idris-dev/pull/1969.diff","patch_url":"https://github.com/idris-lang/Idris-dev/pull/1969.patch"},"body":"This adds two new entries to the dsl specification:\r\n* lambda_named\r\n* let_named\r\nwhich override lambda and let, when present.\r\n\r\nThe use case is when we want to use the AST to translate to another language and keep the variable names similar to the ones used in the AST.\r\n\r\nFor example:\r\n\r\n```haskell\r\ndata Test : Type where\r\n  Var : Nat -> Test\r\n  Lam : Test -> Test\r\n  LamNm : String -> Test -> Test\r\n  Let : Test -> Test -> Test\r\n  LetNm : String -> Test -> Test -> Test\r\n  Lit : Integer -> Test\r\n  Add : Test -> Test -> Test\r\n\r\nplus : Test -> Test -> Test\r\nplus = Add\r\n\r\ndsl test_named {\r\n  let_named = LetNm\r\n  variable = Var\r\n  index_first = Z\r\n  index_next = S\r\n  lambda_named = LamNm\r\n}\r\n\r\ndsl test {\r\n  let = Let\r\n  variable = Var\r\n  index_first = Z\r\n  index_next = S\r\n  lambda = Lam\r\n}\r\n\r\nt1 : Test\r\nt1  = test       (let ztest = (Lit 12) in (let y = (Lit 24) in (ztest `plus` y )))\r\n\r\nt1n : Test\r\nt1n = test_named (let ztest = (Lit 12) in (let y = (Lit 24) in (ztest `plus` y )))\r\n\r\nt2 : Test\r\nt2  = test       (\\x,y => (x `plus` y))\r\n\r\nt2n : Test\r\nt2n = test_named (\\x,y => (x `plus` y))\r\n```\r\n\r\nGives the following:\r\n\r\n```haskell\r\n*test> t1\r\nLet (Lit 12) (Let (Lit 24) (Add (Var 1) (Var 0))) : Test\r\n*test> t1n\r\nLetNm \"ztest\"\r\n      (Lit 12)\r\n      (LetNm \"y\" (Lit 24) (Add (Var 1) (Var 0))) : Test\r\n*test> t2\r\nLam (Lam (Add (Var 1) (Var 0))) : Test\r\n*test> t2n\r\nLamNm \"x\" (LamNm \"y\" (Add (Var 1) (Var 0))) : Test\r\n```"},"comment":{"url":"https://api.github.com/repos/idris-lang/Idris-dev/issues/comments/76681416","html_url":"https://github.com/idris-lang/Idris-dev/pull/1969#issuecomment-76681416","issue_url":"https://api.github.com/repos/idris-lang/Idris-dev/issues/1969","id":76681416,"user":{"login":"david-christiansen","id":115330,"avatar_url":"https://avatars.githubusercontent.com/u/115330?v=3","gravatar_id":"","url":"https://api.github.com/users/david-christiansen","html_url":"https://github.com/david-christiansen","followers_url":"https://api.github.com/users/david-christiansen/followers","following_url":"https://api.github.com/users/david-christiansen/following{/other_user}","gists_url":"https://api.github.com/users/david-christiansen/gists{/gist_id}","starred_url":"https://api.github.com/users/david-christiansen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/david-christiansen/subscriptions","organizations_url":"https://api.github.com/users/david-christiansen/orgs","repos_url":"https://api.github.com/users/david-christiansen/repos","events_url":"https://api.github.com/users/david-christiansen/events{/privacy}","received_events_url":"https://api.github.com/users/david-christiansen/received_events","type":"User","site_admin":false},"created_at":"2015-03-02T09:31:42Z","updated_at":"2015-03-02T09:31:42Z","body":"@jfdm So you're on board with this?"}}