File: OtherFoo.hs

package info (click to toggle)
haskell-vector 0.13.1.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 996 kB
  • sloc: haskell: 11,004; ansic: 6; makefile: 3
file content (30 lines) | stat: -rw-r--r-- 1,191 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
module Inspect.DerivingVia.OtherFoo where

import qualified Data.Vector.Generic         as VG
import qualified Data.Vector.Generic.Mutable as VGM
import qualified Data.Vector.Unboxed         as VU
import GHC.Generics (Generic)


-- | Simple product data type for which we derive Unbox instances
-- using generics and iso-deriving. It's defined in separate module in
-- order to test that it doesn't impede optimizer
data OtherFoo a = OtherFoo Int a
  deriving (Show,Generic)

instance VU.IsoUnbox (OtherFoo a) (Int,a) where

newtype instance VU.MVector s (OtherFoo a) = MV_Int (VU.MVector s (Int, a))
newtype instance VU.Vector    (OtherFoo a) = V_Int  (VU.Vector    (Int, a))

instance VU.Unbox a => VU.Unbox (OtherFoo a)
deriving via (OtherFoo a `VU.As` (Int, a)) instance VU.Unbox a => VGM.MVector VU.MVector (OtherFoo a)
deriving via (OtherFoo a `VU.As` (Int, a)) instance VU.Unbox a => VG.Vector   VU.Vector  (OtherFoo a)