GithubHelp home page GithubHelp logo

Comments (1)

jcpetruzza avatar jcpetruzza commented on May 22, 2024 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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.