Comments (7)
I haven't tested it much, and the name is up for grabs
from adjunctions.
I agree that the Generic1
-based default is rather clunky to use, to the point where I'd be surprised if anyone was actually using it in practice. That default predates DerivingVia
, and if I were to redesign this part of adjunctions
from scratch, I'd reach for a solution similar to yours. That is to say: let's add something like this!
One minor hiccup: although Generically1
now exists in base
, it would require an extremely recent version of base
to use, and we'd like to have a wider GHC support window in adjunctions
. For this reason, I think we should define our own version of Generically1
in adjunctions
, but with a more specific name.
from adjunctions.
It makes sense to add a newtype separate from base. Generically1
doesn't have a configuration parameter anyway.
An 'off-topic' question is how parameters should be handled and what your thoughts are on that. Should they be defined per library or defined in base where there is one common name like Generically
? This comes up in this library but others like json and Arbitrary
.
generic-random offers a suitable candidate for Arbitrary (Generically a)
where everything is generated with uniform probability but it also has newtypes to tinker and customize the instances, is it worth fitting this into a singular mold?
deriving Arbitrary via GenericArbitrary '[2, 3, 5] X
deriving Arbitrary via GenericArbitrary '[1, 2, 3] `AndShrinking` X
deriving Arbitrary via GenericArbitraryRec '[2, 3, 5] X
deriving Arbitrary via GenericArbitraryG CustomGens '[2, 3, 5] X
from adjunctions.
I'm not sure what you mean by "parameters" in the context of adjunctions
. I was imagining that the only thing you'd need to specify is the type to use as the Rep
instance. Are there ever situations where you would want to configure things more than that?
from adjunctions.
For this ticket we just need to add a single newtype that specifies the Rep
type.
Obviously that only works when the generic representation lines up: eventually users will want to specify more intricate isomorphisms. That's not important now though.
I was wondering if all libraries should provide a custom newtype or if GenericallyAs :: Type -> config -> Type
belongs in base or not
from adjunctions.
A similar issue affects Co
as well.
For example, we can only derive Comonad
when Rep
is a monoid
instance (Representable f, Monoid (Rep f)) => Comonad (Co f)
We might wish to have Rep Pair = Bool
but get the Comonad
behaviour via All
or Any
:
deriving Comonad
via CoOf Any Pair
from adjunctions.
For now, my inclination is to do whatever is simplest to specify, and the API you propose in #71 (comment) fits the bill. My opinion is that the design space for type-level configurations is murky enough that it's not worth pursuing hereโat least, not unless more users specifically ask for one point in the design space.
from adjunctions.
Related Issues (20)
- Adjunction f u means f a is isomorphic to (a, Rep u) HOT 1
- instance Representable f => Representable (Reverse f)? HOT 2
- indexM in Representable? HOT 1
- Does this exist or belong somewhere? HOT 2
- Editable representable functors HOT 1
- Add FunctorWithIndex constraint to Representable? HOT 2
- Add withIndex helper function? HOT 4
- Day instances derived from from Compose HOT 2
- representable-functors package HOT 2
- Define 'Representable (Join f)' once we have Bicomonad HOT 1
- List vs. Seq for Rep Cofree
- Place and name of higher Functor
- Add instance for WrappedMonad
- New Representable methods feel cramped HOT 5
- Representable no longer works with GND HOT 4
- fmap @(Co _) should be fmapRep, not stock derived HOT 2
- Exploit the (_ *> as = as) property of Representables in Co HOT 2
- Representable (Kleisli r a) given a phantom 'l' argument
- Not compatible with mtl-2.3.1-rc1 as bounds claim HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from adjunctions.