Add lenses for SPic and MountedObject positions

This commit is contained in:
2026-03-29 16:38:48 +01:00
parent d278083947
commit 00999f5921
4 changed files with 28 additions and 13 deletions
+7
View File
@@ -1,8 +1,10 @@
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE LambdaCase #-}
module Dodge.Data.MountedObject where
import Control.Lens
import ShapePicture.Data
import Geometry.Data
import Data.Aeson
@@ -13,4 +15,9 @@ data MountedObject
| MountedSPic SPic
deriving (Eq, Ord, Show, Read) --Generic, Flat)
moPos :: ASetter' MountedObject Point3
moPos f = \case
MountedLight p r c -> Identity $ MountedLight (runIdentity $ f p) r c
MountedSPic sp -> Identity . MountedSPic $ sp & spPos %~ (runIdentity . f)
deriveJSON defaultOptions ''MountedObject