{"id":22018915,"url":"https://github.com/thautwarm/fstan","last_synced_at":"2025-08-11T14:48:08.885Z","repository":{"id":97223495,"uuid":"163154242","full_name":"thautwarm/FSTan","owner":"thautwarm","description":"Higher abstraction infrastructures in F#(ad-hoc polymorphism, subtypeclassing, monad, hkt...), exactly what we've dreamed about for so long","archived":false,"fork":false,"pushed_at":"2019-06-02T01:29:04.000Z","size":78,"stargazers_count":43,"open_issues_count":0,"forks_count":4,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-06-09T06:03:53.251Z","etag":null,"topics":["functional-programming","higher-kinded-types","monad","monoids","subtypeclassing","typeclasses"],"latest_commit_sha":null,"homepage":"","language":"F#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thautwarm.png","metadata":{"files":{"readme":"README.md","changelog":null,"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,"zenodo":null}},"created_at":"2018-12-26T08:09:10.000Z","updated_at":"2025-03-25T12:34:18.000Z","dependencies_parsed_at":"2023-05-03T21:30:58.431Z","dependency_job_id":null,"html_url":"https://github.com/thautwarm/FSTan","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/thautwarm/FSTan","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thautwarm%2FFSTan","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thautwarm%2FFSTan/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thautwarm%2FFSTan/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thautwarm%2FFSTan/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thautwarm","download_url":"https://codeload.github.com/thautwarm/FSTan/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thautwarm%2FFSTan/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269906322,"owners_count":24494329,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-11T02:00:10.019Z","response_time":75,"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":["functional-programming","higher-kinded-types","monad","monoids","subtypeclassing","typeclasses"],"created_at":"2024-11-30T05:14:37.902Z","updated_at":"2025-08-11T14:48:08.852Z","avatar_url":"https://github.com/thautwarm.png","language":"F#","readme":"# FSTan\n\nExactly a full-featured and practical implementation typeclasses and higher kinded types in F#.\n\nFor manuals check [Guide.md](https://github.com/thautwarm/FSTan/blob/master/Guide.md), where you'll be told how to use these concise typeclasses, higher kinded types and constraints.\n\n\n\n## Motivation and Features\n\nThere are also other similar implementations in FSharp like `Higher` and `FSharpPlus`, but they're not able to provide all the features listed below, which motivate me to create a better one:\n\n- Support instance resolution.\n- Support ad-hoc polymorphism.\n- Support to create a typeclass and add constraints to it.\n- Support subtypeclassing.\n- Support to directly access type constructor.\n- Support default implementations for typeclass.\n- All above operations are quite lightweighted and not implemented in a magic way.\n\nYes, exactly, it's a what many and I have dreamed about for so long.\n\n\n## Limitation\n\n1. The performance might hurt in some scenarios, for each the datatype works with\nhigher kinded types have to be upcasted to an unique abstract class, for instance,\n`maybe\u003c'a\u003e` has to be casted to `hkt\u003cMaybe, 'a\u003e`.\n\n2. For some builtin datatypes cannot be interfaced with `hkt`, an extra wrapper class is\nrequired to work with higher kined types.\n\n    For instance, interface type `listData\u003c'a\u003e` is required for the builtin `List\u003c'a\u003e`.\n\n    You can use `wrap` and `unwrap` to transform datatypes from `List\u003c'a\u003e` to `hkt\u003cmkList\u003cListSig\u003e,'a\u003e`, vice versa.\n\n   ```FSharp\n    module List' = List\n    type List'\u003c'a\u003e = List\u003c'a\u003e\n\n\n    type mkList\u003c'L\u003e() =\n        inherit monad\u003cmkList\u003c'L\u003e\u003e()\n            static member wrap\u003c'a\u003e (x : List'\u003c'a\u003e): hkt\u003cmkList\u003c'L\u003e, 'a\u003e =\n                {wrap = x} :\u003e _\n            static member unwrap\u003c'a\u003e (x : hkt\u003cmkList\u003c'L\u003e, 'a\u003e): List'\u003c'a\u003e =\n                (x :?\u003e _).wrap\n\n            default si.bind\u003c'a, 'b\u003e (m: hkt\u003cmkList\u003c'L\u003e, 'a\u003e) (k: 'a -\u003e hkt\u003cmkList\u003c'L\u003e, 'b\u003e): hkt\u003cmkList\u003c'L\u003e, 'b\u003e =\n                wrap \u003c| List'.collect (unwrap \u003c\u003c k) (unwrap m)\n\n            default si.pure'\u003c'a\u003e (a: 'a): hkt\u003cmkList\u003c'L\u003e, 'a\u003e = wrap \u003c| [a]\n            interface show\u003cmkList\u003c'L\u003e\u003e with\n                member si.show (x: hkt\u003cmkList\u003c'L\u003e, 'a\u003e) =\n                    let x = unwrap x\n                    x.ToString()\n\n    and listData\u003c'L, 'a\u003e =\n        {wrap : List'\u003c'a\u003e}\n        interface hkt\u003cmkList\u003c'L\u003e, 'a\u003e\n\n\n   // create a concrete List type\n   type ListSig() =\n    // default implements following type classes:\n    // - monad (functor and applicative are implemented simultaneously)\n    // - show\n\n    inherit mkList\u003cListSig\u003e()\n   type list\u003c'a\u003e = hkt\u003cmkList\u003cListSig\u003e, 'a\u003e\n\n   let test() =\n\n        let listm: _ list = Do {\n            let! x = wrap [1, 2, 3]\n            wrap [x]\n        }\n        // listm : resolved to be list\u003cint\u003e\n\n        let f (x: int) : string = \"\"\n        fmap f listm\n        // return value is resolved to be list\u003cstring\u003e\n   ```\n3. Cannot implement instance for datatypes that are not constructed by a type constructor.\nFor instance, you cannot implement any typeclass for all primitives types like integers, floats and so on, unless you wrap them with an `Identity` type constructor.\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthautwarm%2Ffstan","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthautwarm%2Ffstan","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthautwarm%2Ffstan/lists"}