packages feed

geomancy-0.4.0.0: src/Geomancy/Swizzle/UVec/Extend.hs

{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# OPTIONS_GHC -Wno-orphans #-}

module Geomancy.Swizzle.UVec.Extend () where

import GHC.Records (HasField(..))

import Geomancy.UVec2 (UVec2, withUVec2)
import Geomancy.UVec3 (UVec3, uvec3, withUVec3)
import Geomancy.UVec4 (UVec4, uvec4)

instance HasField "xy0" UVec2 UVec3 where
  {-# INLINE getField #-}
  getField v = withUVec2 v \x y -> uvec3 x y 0

instance HasField "xy1" UVec2 UVec3 where
  {-# INLINE getField #-}
  getField v = withUVec2 v \x y -> uvec3 x y 1

instance HasField "xy00" UVec2 UVec4 where
  {-# INLINE getField #-}
  getField v = withUVec2 v \x y -> uvec4 x y 0 0

instance HasField "xy01" UVec2 UVec4 where
  {-# INLINE getField #-}
  getField v = withUVec2 v \x y -> uvec4 x y 0 1

instance HasField "xy10" UVec2 UVec4 where
  {-# INLINE getField #-}
  getField v = withUVec2 v \x y -> uvec4 x y 1 0

instance HasField "xy11" UVec2 UVec4 where
  {-# INLINE getField #-}
  getField v = withUVec2 v \x y -> uvec4 x y 1 1

instance HasField "xyz0" UVec3 UVec4 where
  {-# INLINE getField #-}
  getField v = withUVec3 v \x y z -> uvec4 x y z 0

instance HasField "xyz1" UVec3 UVec4 where
  {-# INLINE getField #-}
  getField v = withUVec3 v \x y z -> uvec4 x y z 1