{"id":22317875,"url":"https://github.com/ken-okabe/vscode-lambda-for-fun-fsharp","last_synced_at":"2026-04-18T02:07:20.271Z","repository":{"id":146182506,"uuid":"528589962","full_name":"ken-okabe/vscode-lambda-for-fun-fsharp","owner":"ken-okabe","description":"Write Haskell style lambda expression in F#, `\\` instead of `fun `","archived":false,"fork":false,"pushed_at":"2023-01-11T21:43:14.000Z","size":89,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-26T03:42:21.972Z","etag":null,"topics":["dotnet","dotnet-framework","fsharp","functional-programming","haskell","lambda","lambda-calculus","lambda-expressions","lambda-functions","visual-studio-code"],"latest_commit_sha":null,"homepage":"https://marketplace.visualstudio.com/items?itemName=KenOkabe.lambda-for-fun-fsharp","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ken-okabe.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-08-24T20:49:55.000Z","updated_at":"2023-03-02T01:41:48.000Z","dependencies_parsed_at":null,"dependency_job_id":"8fddb113-1a02-465c-9a44-928a743638e6","html_url":"https://github.com/ken-okabe/vscode-lambda-for-fun-fsharp","commit_stats":null,"previous_names":["ken-okabe/vscode-lambda-for-fun-fsharp"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/ken-okabe/vscode-lambda-for-fun-fsharp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ken-okabe%2Fvscode-lambda-for-fun-fsharp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ken-okabe%2Fvscode-lambda-for-fun-fsharp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ken-okabe%2Fvscode-lambda-for-fun-fsharp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ken-okabe%2Fvscode-lambda-for-fun-fsharp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ken-okabe","download_url":"https://codeload.github.com/ken-okabe/vscode-lambda-for-fun-fsharp/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ken-okabe%2Fvscode-lambda-for-fun-fsharp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31953517,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T00:39:45.007Z","status":"online","status_checked_at":"2026-04-18T02:00:07.018Z","response_time":103,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dotnet","dotnet-framework","fsharp","functional-programming","haskell","lambda","lambda-calculus","lambda-expressions","lambda-functions","visual-studio-code"],"created_at":"2024-12-03T23:11:36.861Z","updated_at":"2026-04-18T02:07:20.255Z","avatar_url":"https://github.com/ken-okabe.png","language":"TypeScript","readme":"# [Deprecated]Lambda for fun F#\n\n![](https://user-images.githubusercontent.com/1316994/186539882-d2c7acd2-a698-4547-83ba-40ba7e3400ad.png)\n\n**Write Haskell style Lambda Expression in F#:**\n`\\x` instead of `fun x`\n\n#### Before\n\n![](https://user-images.githubusercontent.com/1316994/186543152-04ee1a19-f2f7-4c36-91fa-97045a9a1002.png)\n\n#### After\n![](https://user-images.githubusercontent.com/1316994/186543220-53564220-a026-4e58-be33-e7fb8f07ceb4.png)\n\n#### Even in Comments\n\n![](https://user-images.githubusercontent.com/1316994/186546918-b55d6ce7-abe3-486a-b5e6-316d9b98f4e9.png)\n\n## Deprecated\n\nPlease use the below instead\n\n---\n\n\u003e ## [Conceal for VSCode](https://marketplace.visualstudio.com/items?itemName=BRBoer.vsc-conceal)\n\n\u003eConceal makes *visual* substitutions to your source code, e.g. displaying `fun` as `λ`, while never touching your code.\n\n\u003eThis feature is inspired by [prettify-symbols-mode for Emacs](https://www.emacswiki.org/emacs/PrettySymbol) and is the unofficial successor of [vsc-prettify-symbols-mode](https://github.com/siegebell/vsc-prettify-symbols-mode).\n\nConfiguration for `fun ` to `\\`\n\n```json\n\"conceal.substitutions\": [{\n    \"language\": \"fsharp\",\n            \"substitutions\": [\n                {\n                    \"ugly\": \"fun \",\n                    \"pretty\": \"\\\\\",\n                    \"pre\": \"\\\\b\"\n                }\n            ]\n}]\n```\n\n### `[Alt] + \\` will type the virtual `\\`\n\n`keybinding.json` as below:\n\n\n```json\n[\n\t{\n\t\t\"key\": \"alt+\\\\\",\n\t\t\"command\": \"editor.action.insertSnippet\",\n\t\t\"when\": \"editorFocus \u0026\u0026 editorLangId == 'fsharp'\",\n\t\t\"args\": {\n\t\t\t\"snippet\": \"fun $1\"\n\t\t}\n\t}\n]\n ```\n\n\n----\n----\n\n----\n\n## Features and benefits\n✓  [Proven syntax in Haskell for Lambda Expressions](https://wiki.haskell.org/Monad_laws) that corresponds directly to [F# legacy `fun_` syntax](https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/functions/lambda-expressions-the-fun-keyword)\n\n✓  You can enjoy the concise Haskell style Lambda Expression before the official implementation without messing your code\n\n✓  The F# code only appears so virtually on the VSCode editor with this extension, Nothing changes\n\n✓  Simple design, No command, Just do the single task, Works out-of-the-box!\n\n## How is this possible?\n\nCSS with VSCode editor decorator API. VSCode is built on the Web Technology!\n\n[microsoft/vscode-extension-samples/decorator-sample/](https://github.com/microsoft/vscode-extension-samples/tree/main/decorator-sample)\n\nAlthough I observed the official sample code is not written smartly in FunctionalProgramming style, this extension is derived from it with minimal code modifications.\n\nThe majority of the trick comes from CSS modification.\n\nInspired by the great work of **Inline fold** extension @[Marketplace](https://marketplace.visualstudio.com/items?itemName=moalamri.inline-fold)/[GitHub Repo](https://github.com/moalamri/vscode-inline-fold), here is the core implementation of the decorator CSS.\n\n\n---\n\n```typescript\n// create a decorator type that we use to decorate the matched keyword\ndecorationType = vscode.window.createTextEditorDecorationType(\n  {\n    before: {\n      contentText: \"\\\\\",\n      color: config.color,\n    },\n    textDecoration: \"none; display: none;\",\n  }\n);\n```\n\nSo, this CSS works as below:\n\nSTEP 1: Add `\\` (virtual not real text, like the other type hints) `before` the `fun_`\n\n![](https://user-images.githubusercontent.com/1316994/186554283-731f85f8-5c11-4f55-8d7b-fc93c030ce75.png)\n\nSTEP 2: Hide the `fun_` (real text) virtually\n\n![](https://user-images.githubusercontent.com/1316994/186554178-1c263f6d-38a2-43f0-8285-18ccd1eea9f1.png)\n\n---\n\nI also tried `after` scenario instead of `before`, but it doesn't work well at all.\n\n\n## Known Issues\n\nThe `fun_` is hidden by CSS, but actually remains to exist as the real element on the VSCode text editor, and the same applies to the real cursor move. Therefore, the cursor move around `\\` make you feel against your standard editing experience.\n\n## How to delete such a virtual existence??\n\nJust try to delete, and it works!\n\n![](https://user-images.githubusercontent.com/1316994/186556895-96fda207-eefd-4b7b-9001-8729861b86c1.png)\n\nWhen you try to delete the virtual `\\`, you will actually delete the real SPACE at the end of `fun_`. This will collapse the regex match for `fun_` including the last space, so `funx` will emerge on the surface of the text editor.\n\n## How to type the virtual `\\` ?\n\n`[Alt] + \\` will type the virtual `\\` as the default setting as below:\n\n\n```json\n\"keybindings\": [\n\t{\n\t\t\"key\": \"alt+\\\\\",\n\t\t\"command\": \"editor.action.insertSnippet\",\n\t\t\"when\": \"editorFocus \u0026\u0026 editorLangId == 'fsharp'\",\n\t\t\"args\": {\n\t\t\t\"snippet\": \"fun $1\"\n\t\t}\n\t}\n]\n ```\n\nIf you want to change the keybinding, you should be able to [access and manage VSCode keybindings](https://code.visualstudio.com/docs/getstarted/keybindings).\n\n## How to Get Started?\n\nJust Install then it should work out-of-the-box!\n\nThis extension will be activated on every event so supposedly, reboot of VSCode or reopening F# code editor is not required.\n\nAfter the activation of this extension, a couple of TextEditor events are monitored and if the document is F# document (the language id is `fsharp`), after a certain delay (100 milliseconds as default), it will trigger `updateDecorations` that includes regex search.\n\nThis delay mechanism is directly derived as it is in the Microsoft official sample code, and I have not touched.\n\n```typescript\n// when supported languages, some smart delay update\n// the inner code is derived from MS official sample\nfunction triggerUpdateDecorations(throttle: boolean, editor: vscode.TextEditor) {\n\n  editor.document.languageId === \"fsharp\"\n\n    ? (() =\u003e {\n      if (timeout) {\n        clearTimeout(timeout);\n        timeout = undefined;\n      }\n      if (throttle) {\n        timeout = setTimeout(updateDecorations, delay);\n      } else {\n        updateDecorations();\n      }\n    })()\n    : (() =\u003e { })();\n\n}\n```\n\nProbably it's implemented as so to avoid jamming events by user key strokes in a short period of the time.\n\n\n## Requirements\n\nVisualStudioCode 1.70.0 or higher\n\n## Install\n\nJust use the GUI or CUI of VSCode that you know already.\n\n## Extension Settings\n\nThis extension is designed to run out-of-the-box for your F# Code!\n\nThe 3 settings are available:\n\n#### Decoration color of lambda backslash(`\\`)\n\n`lambda-for-fun-fsharp.color` : `#68D7AC`\n\n#### Delay milliseconds of updateDecorations\n\n`lambda-for-fun-fsharp.delay` : `100`\n\n#### Regex to identify `fun_`\n\n`lambda-for-fun-fsharp.regex` : *empty*\n\n\n## Regex to match `fun_` keyword\n\nThe value for `lambda-for-fun-fsharp.regex`  is *empty* as default, and a hardcoded regex as seen in the URL below will be used :\n\nhttps://regex101.com/r/U9IeWI/1\n\nWhen you want to try a better regex, after testing at the site, Copy it manually except the head `/` and tail `\\g`, then Paste at the form of `lambda-for-fun-fsharp.regex`.\n\n![](https://user-images.githubusercontent.com/1316994/186560830-6e562ddd-31f6-433f-a784-1eef55e2a732.png)\n\n\n## Your contribution is highly appreciated\n\nIf you have some idea for improvement, better regex or any other issues, please join\n\nhttps://github.com/stken2050/vscode-lambda-for-fun-fsharp/issues\n\n---\n\n**Enjoy F# Coding!**\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fken-okabe%2Fvscode-lambda-for-fun-fsharp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fken-okabe%2Fvscode-lambda-for-fun-fsharp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fken-okabe%2Fvscode-lambda-for-fun-fsharp/lists"}