geomancy-0.4.0.0: src/Geomancy/Swizzle/DVec/Extend.hs
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# OPTIONS_GHC -Wno-orphans #-}
module Geomancy.Swizzle.DVec.Extend () where
import GHC.Records (HasField(..))
import Geomancy.DVec2 (DVec2, withDVec2)
import Geomancy.DVec3 (DVec3, dvec3, withDVec3)
import Geomancy.DVec4 (DVec4, dvec4)
instance HasField "xy0" DVec2 DVec3 where
{-# INLINE getField #-}
getField v = withDVec2 v \x y -> dvec3 x y 0
instance HasField "xy1" DVec2 DVec3 where
{-# INLINE getField #-}
getField v = withDVec2 v \x y -> dvec3 x y 1
instance HasField "xy00" DVec2 DVec4 where
{-# INLINE getField #-}
getField v = withDVec2 v \x y -> dvec4 x y 0 0
instance HasField "xy01" DVec2 DVec4 where
{-# INLINE getField #-}
getField v = withDVec2 v \x y -> dvec4 x y 0 1
instance HasField "xy10" DVec2 DVec4 where
{-# INLINE getField #-}
getField v = withDVec2 v \x y -> dvec4 x y 1 0
instance HasField "xy11" DVec2 DVec4 where
{-# INLINE getField #-}
getField v = withDVec2 v \x y -> dvec4 x y 1 1
instance HasField "xyz0" DVec3 DVec4 where
{-# INLINE getField #-}
getField v = withDVec3 v \x y z -> dvec4 x y z 0
instance HasField "xyz1" DVec3 DVec4 where
{-# INLINE getField #-}
getField v = withDVec3 v \x y z -> dvec4 x y z 1