revamp Parameterized typeclass and add misc additional functionality #450
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I've put everything non-experimental in #447 in this PR because these things are ready to be merged and make live easier for everyone.
The biggest change is the new
Torch.Typed.Parameter.Parameterized
type class:The old one was:
The new one doesn't have functional dependencies, has one type parameter less, uses default signatures to delegate implementations to generics, and provides the
Parameters
type family that computes the list of parameters for a given model ADT.You can use
DeriveAnyClass
with thederiving
syntax now to ask for aParameterized
instance for any model ADT that has aGeneric
instance:If this compiles, you can use
Parameters MyModel
to ask GHC for the list of parameters of your model. Within ghci, this would be:or something to that effect. (This example has no parameters, therefore the empty type-level list.)