GithubHelp home page GithubHelp logo

Comments (4)

JohnLato avatar JohnLato commented on June 12, 2024

I don't think this is currently fixable within vector. Role annotations
aren't allowed on type or data families currently, and I don't know any
other way to get ghc to make the coercion.

For now, I've used
http://hackage.haskell.org/package/vector-th-unbox instead of GND.
On Apr 15, 2014 4:44 AM, "Edgar Gomes" [email protected] wrote:

Some of my code is broken with the newest version of ghc (7.8.2).

I'm using GeneralizedNewtypeDeriving to deriving instances of
Data.Vector.Unbox using the following:

data VoxelPos = VoxelPos
{-# UNPACK #-} !Int
{-# UNPACK #-} !Int
{-# UNPACK #-} !Int
deriving (Show, Eq, Ord)

newtype FacePos = FacePos VoxelPos deriving ( Eq, Hashable, NFData, G.Vector U.Vector, M.MVector U.MVector, U.Unbox)

where VoxelPos have manual rolled instances using (Int, Int, Int):

newtype instance U.MVector s VoxelPos = MV_VoxelPos (U.MVector s (Int, Int, Int))
newtype instance U.Vector VoxelPos = V_VoxelPos (U.Vector (Int, Int, Int))
instance U.Unbox VoxelPos
instance M.MVector U.MVector VoxelPos where
basicLength (MV_VoxelPos v) ...
...

and this was working with the previous versions of ghc. But after
upgrading ghc, I get the following error:

Could not coerce from ‘U.MVector s (Int, Int, Int)’ to ‘U.MVector
s FacePos’
because the second type argument of ‘U.MVector’ has role Nominal,
but the arguments ‘(Int, Int, Int)’ and ‘FacePos’ differ
arising from the coercion of the method ‘M.basicLength’ from type
‘forall s. U.MVector s VoxelPos -> Int’ to type
‘forall s. U.MVector s FacePos -> Int’
Possible fix:
use a standalone 'deriving instance' declaration,
so you can specify the instance context yourself
When deriving the instance for (M.MVector U.MVector FacePos)
which, I think, is because of addition of roles. I know that roles improves safety when using GeneralizedNewtypeDeriving which is, of course, really good!

What are the possible solutions to solve this?
It seems necessary to enforce the role of MVector, something like this:

type role MVector _ representational


Reply to this email directly or view it on GitHubhttps://github.com//issues/16
.

from vector.

hvr avatar hvr commented on June 12, 2024

See also recent thread on glasgow-haskell-users

from vector.

cartazio avatar cartazio commented on June 12, 2024

this is a ghc side problem that we can't fix in vector, and requires some future evolution of ghc's Roles tooling to enable again

from vector.

cartazio avatar cartazio commented on June 12, 2024

closing because ghc doesn't have higher kinded roles, so we cant help GND sadness here

from vector.

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.