{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreify3p6e6xhmrcmr4mobkuv45kzlrbzn3pxbtplmvzt5cqrg7n655m",
"uri": "at://did:plc:pi6woz4d47bkuws673w2il2r/app.bsky.feed.post/3mjelpiwps5t2"
},
"path": "/t/type-level-programming-dealing-with-ambiguous-type-error/13828#post_10",
"publishedAt": "2026-04-13T09:48:57.000Z",
"site": "https://discourse.haskell.org",
"textContent": "AriFordsham:\n\n> Having said that, there is a feature of `RequiredTypeArguments` that I do like. Until now, the only way to go from `type (or data kind) -> term` was with a typeclass. this has the disadvantage of a) unwieldly syntax (for this use case) and b) It doesn’t support closed classes. By RTA allows me to pattern-match on types in function syntax, which is nice.\n\nCould you give an example of what you mean here? It sounds like you’re saying it’s possible to do something like this:\n\n\n f :: forall (a :: Type) -> Int\n f Int = 0\n f Bool = 1\n\n\nBut that gives an error:\n\n\n • Couldn't match expected type ‘a’ with actual type ‘Int’\n ‘a’ is a rigid type variable bound by\n the type signature for:\n f :: forall a -> Int\n • In the pattern: Int\n In an equation for ‘f’: f Int = 0\n",
"title": "Type level programming: Dealing with ambiguous type error"
}