Comments (1)
I think you are definitely right, and we should be able to handle this case. Conceptually, the main thing that we are missing is to allow the functor argument (e.g. m
in LogCap m
) to occur under another functor when deriving FunctorB
(and similarly for the other classes). At the moment we allow a barbie type to occur under a functor (e.g. Maybe (LogCap m)
), but not the functor argument itself. This shouldn't be hard to fix.
Because we have an instance Functor (-> r)
, this addition alone would let us handle simpler capability records such as:
data LogCap (m :: Type -> Type)
{ logInfo :: String -> m ()
, logError :: String -> m ()
}
deriving (Generic)
instance FunctorB LogCap
Of course, one would like to handle functions with an arbitrary number of parameters (not just one) or, more generally, an unlimited number of nested functors. This is in fact a bit tricky; but ultimately doable, I think (e.g., one could identify arbitrary chains of functor applications in the generic representation of the type, coerce the type into a version where all the functors were smashed into one using Compose
, operate on that single functor, and then coerce it back to the original representation).
A quicker workaround, would be to do a manual unrolling defining k
instances of the form "the functor argument occurs under {1,2,3,...k} functors".
from barbies.
Related Issues (20)
- Nested or recursive barbies? HOT 6
- Type errors on GHC 8.8 HOT 2
- Laws for ProductB are overly restrictive HOT 4
- Does not compile with ghc 8.8.1 HOT 2
- Field name API? HOT 1
- Template Haskell helper HOT 3
- Lifting Semigroup and Monoid instance HOT 4
- Pushing applicative effects in? HOT 30
- Expand the Wear type family a bit HOT 13
- bzipWithCF HOT 4
- ConstraintsT applied to type parameter? HOT 2
- Compilation failure on GHC 9 HOT 3
- Add `Co` constructor for turning products into sums and vice versa HOT 11
- Release 2.0.3 to Hackage HOT 1
- Couple things that might be useful to have HOT 9
- Tests fail to build on ghc 9.2.1 HOT 4
- Compilation error on GHC 9.2.2 HOT 2
- `ConstraintsB` can't be derived for data family? HOT 2
- ghc bug: "Iface type variable out of scope" HOT 2
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 barbies.