packages feed

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

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

module Geomancy.Swizzle.IVec.Extend () where

import GHC.Records (HasField(..))

import Geomancy.IVec2 (IVec2, withIVec2)
import Geomancy.IVec3 (IVec3, ivec3, withIVec3)
import Geomancy.IVec4 (IVec4, ivec4)

instance HasField "xy0" IVec2 IVec3 where
  {-# INLINE getField #-}
  getField v = withIVec2 v \x y -> ivec3 x y 0

instance HasField "xy1" IVec2 IVec3 where
  {-# INLINE getField #-}
  getField v = withIVec2 v \x y -> ivec3 x y 1

instance HasField "xy00" IVec2 IVec4 where
  {-# INLINE getField #-}
  getField v = withIVec2 v \x y -> ivec4 x y 0 0

instance HasField "xy01" IVec2 IVec4 where
  {-# INLINE getField #-}
  getField v = withIVec2 v \x y -> ivec4 x y 0 1

instance HasField "xy10" IVec2 IVec4 where
  {-# INLINE getField #-}
  getField v = withIVec2 v \x y -> ivec4 x y 1 0

instance HasField "xy11" IVec2 IVec4 where
  {-# INLINE getField #-}
  getField v = withIVec2 v \x y -> ivec4 x y 1 1

instance HasField "xyz0" IVec3 IVec4 where
  {-# INLINE getField #-}
  getField v = withIVec3 v \x y z -> ivec4 x y z 0

instance HasField "xyz1" IVec3 IVec4 where
  {-# INLINE getField #-}
  getField v = withIVec3 v \x y z -> ivec4 x y z 1