What is Nostr?
YoshikuniJujo
npub1a7y…fdm2
2025-01-14 01:00:27
in reply to nevent1q…f20k

YoshikuniJujo on Nostr: ...

引数については、型クラスを利用して多相的になっているので、

Swz.zxy (1, 2, 3) -- (3, 1, 2)
Swz.zxy (1, 2, 3, 4, 5) -- (3, 1, 2)

みたいにできる。さらに

data Argb = Argb Alpha Red Green Blue deriving (Show, Generic)

instance Swizzle1 Argb where type X Argb = Alpha
instance Swizzle2 Argb where type Y Argb = Red
instance Swizzle3 Argb where type Z Argb = Green
instance Swizzle4 Argb where type W Argb = Blue

みたいにすれば、

someColor = Argb a r g b

rgba :: (Red, Green, Blue, Alpha)
rgba = Swz.yzwx someColor

みたいに使える。
Author Public Key
npub1a7y7u324paehw2zdx8jfl3t72ue0ls4etfalxhg0z2gad738savqhxfdm2