How do I write a Data.Vector.Unboxed instance in Haskell?

有些话、适合烂在心里 提交于 2019-12-02 22:44:27

The Unbox type class doesn't have any methods -- it's just shorthand for the Vector and MVector type classes. Derive those, and the Unbox class comes for free (either via deriving or by just writing instance U.Unbox Score on its own line somewhere).

{-# LANGUAGE GeneralizedNewtypeDeriving #-}
import Data.Vector.Generic.Base
import Data.Vector.Generic.Mutable
import qualified Data.Vector.Unboxed as U
newtype Score = Score Double deriving (Vector U.Vector, MVector U.MVector, U.Unbox)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!