Coder Social home page Coder Social logo

Comments (3)

ndmitchell avatar ndmitchell commented on September 20, 2024

Any reason for not doing:

{-# LANGUAGE DeriveFunctor #-}
module Test where
newtype WrappedFunctor f a = WrapFunctor (f a)
    deriving Functor

The deriving functor was added to Derive as a prototype for the GHC version. It's pretty complex, and testing suggests the GHC one got some improvements after that.

from derive.

RyanGlScott avatar RyanGlScott commented on September 20, 2024

I'm not planning on using this in production code. I was just curious to see if derive was capable of handling this case, since I'm working on a similar Template Haskell-based project for deriving Bifunctor instances, so I wanted to take some inspiration from derive.

Am I correct in assuming that if derive sees a type variable of kind * -> * that it makes it an instance of Functor? Or does it do something more complex?

from derive.

ndmitchell avatar ndmitchell commented on September 20, 2024

I've no real idea. The code is at https://github.com/ndmitchell/derive/blob/master/Data/Derive/Functor.hs and https://github.com/ndmitchell/derive/blob/master/Data/Derive/Internal/Traversal.hs. I didn't write it, but you're free to reuse what you can. I suspect it's not looking at the kind info at all, since I don't think the version of TH that it was written provided that.

Should you wish to submit patches for your Bifunctor derivation to Derive and ship your derivation that way, I'd be happy to accept them.

Given that there's probably no great reason to use the Functor instance, and fixing it is probably not trivial, I'll close this ticket and just accept it as an expected limitation.

from derive.

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.