<commit_before>{-# LANGUAGE ForeignFunctionInterface #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
module Graphics.OpenEXR.RGBA where

import Data.Bits
import Data.Function (on)
import Data.Word
import Foreign.Ptr
import Foreign.C.Types
import Foreign.Storable

#include <ImfCRgbaFile.h>

data RGBA = RGBA !Half !Half !Half !Half deriving (Eq,Show)

instance Storable RGBA where
  sizeOf _ = (#size ImgRgba)
  alignment = sizeOf
  peek p = do
    r <- (#peek ImgRgba, r) p
    g <- (#peek ImgRgba, g) p
    b <- (#peek ImgRgba, b) p
    a <- (#peek ImgRgba, a) p
    return $! RGBA r g b a
  poke p (RGBA r g b a) = do
    (#poke ImgRgba, r) p r
    (#poke ImgRgba, g) p g
    (#poke ImgRgba, b) p b
    (#poke ImgRgba, a) p a

instance Num RGBA where
  RGBA a b c d + RGBA a' b' c' d' = RGBA (a + a') (b + b') (c + c') (d + d')
  RGBA a b c d - RGBA a' b' c' d' = RGBA (a - a') (b - b') (c - c') (d - d')
  RGBA a b c d * RGBA a' b' c' d' = RGBA (a * a') (b * b') (c * c') (d * d')
  negate (RGBA a b c d) = RGBA (negate a) (negate b) (negate c) (negate d)
  abs (RGBA a b c d) = RGBA (abs a) (abs b) (abs c) (abs d)
  signum (RGBA a b c d) = RGBA (signum a) (signum b) (signum c) (signum d)
  fromInteger a = RGBA n n n n where n = fromInteger a<commit_msg>fix for the RGBA storable instance<commit_after>{-# LANGUAGE ForeignFunctionInterface #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
module Graphics.OpenEXR.RGBA where

import Foreign.Storable
import Graphics.OpenEXR.Half

#include <ImfCRgbaFile.h>

data RGBA = RGBA !Half !Half !Half !Half deriving (Eq,Ord,Show)

instance Storable RGBA where
  sizeOf _ = (#size ImfRgba)
  alignment = sizeOf
  peek p = do
    r <- (#peek ImfRgba, r) p
    g <- (#peek ImfRgba, g) p
    b <- (#peek ImfRgba, b) p
    a <- (#peek ImfRgba, a) p
    return $! RGBA r g b a
  poke p (RGBA r g b a) = do
    (#poke ImfRgba, r) p r
    (#poke ImfRgba, g) p g
    (#poke ImfRgba, b) p b
    (#poke ImfRgba, a) p a

instance Num RGBA where
  RGBA a b c d + RGBA a' b' c' d' = RGBA (a + a') (b + b') (c + c') (d + d')
  RGBA a b c d - RGBA a' b' c' d' = RGBA (a - a') (b - b') (c - c') (d - d')
  RGBA a b c d * RGBA a' b' c' d' = RGBA (a * a') (b * b') (c * c') (d * d')
  negate (RGBA a b c d) = RGBA (negate a) (negate b) (negate c) (negate d)
  abs (RGBA a b c d) = RGBA (abs a) (abs b) (abs c) (abs d)
  signum (RGBA a b c d) = RGBA (signum a) (signum b) (signum c) (signum d)
  fromInteger a = RGBA n n n n where n = fromInteger a
{'fraction_non_alphanumeric': 0.15263963274674827, 'fraction_numerical': 0.0, 'mean_word_length': 2.784370477568741, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1275583', 'n_tokens_mistral': 1236, 'n_tokens_neox': 1147, 'n_words': 433}