haskell / haskell/core-libraries-committee
Add `applyTypes` to Type.Reflection or Data.Dynamic
- Dominant language
- Haskell
- Stars
- 109
- Forks
- 20
- PR merge metrics
- No merged PRs in 30d
Description
I have implemented and used this handy function for a compiler (Hell), that simply applies two type reps:
```haskell
-- | Apply a type `f' with an argument `x', if it is a type function,
-- and the argument is of the right kind.
applyTypes :: SomeTypeRep -> SomeTypeRep -> Maybe SomeTypeRep
applyTypes (SomeTypeRep f) (SomeTypeRep x) =
case Type.typeRepKind f of
Type.App (Type.App (-->) a) _b
| Just Type.HRefl <- Type.eqTypeRep (-->) (TypeRep @(->)) ->
case Type.eqTypeRep (Type.typeRepKind x) a of
Just Type.HRefl ->
Just $ SomeTypeRep $ Type.App f x
_ -> Nothing
_ -> Nothing
```
Any objections to putting this in Type.Reflection? There’s a similar function in Data.Dynamic for applying functions that are encased in Dynamic, so I wouldn’t mind if it sat in there, either.
I’m not married to the name, either. As long as the type signature and behaviour is right.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reading README.md and PROPOSALS.md, then compare the existing Type.Reflection and Data.Dynamic APIs mentioned in the proposal. Review the supplied applyTypes signature and behavior, including kind checking. Done means the committee has settled the module placement, name, signature, and behavior sufficiently for an implementation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- haskell
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100