Refactor modules

This commit is contained in:
jgk
2021-07-25 01:29:43 +02:00
parent e453065afe
commit 84a9badea8
38 changed files with 77 additions and 48 deletions
+8 -1
View File
@@ -1,9 +1,12 @@
--{-# LANGUAGE TemplateHaskell #-}
--{-# LANGUAGE Strict #-}
{-# LANGUAGE DeriveGeneric #-}
module Picture.Data
where
import Geometry.Data
import GHC.Generics (Generic)
import Control.DeepSeq
import Data.Foldable
--import qualified Data.List as L
--import Data.Monoid
@@ -29,6 +32,8 @@ data RenderType
| Render22x4 {_unRender22x4 :: ((Point2,Point2),Point4)}
| Render3x2 {_unRender3x2 :: (Point3,Point2)}
| Render3x3 {_unRender3x3 :: (Point3,Point3)}
deriving Generic
instance NFData RenderType
type RGBA = (Float,Float,Float,Float)
type Color = (Float,Float,Float,Float)
@@ -47,11 +52,13 @@ instance Functor FTree where
fmap f (FBranches ts) = FBranches $ fmap (fmap f) ts
fmap f (FLeaf x) = FLeaf (f x)
{-# INLINE fmap #-}
{- Tree with values at and only at the leaves. -}
data LTree a
= LBranches [LTree a]
| LLeaf a
deriving (Generic)
instance NFData a => NFData (LTree a)
instance Foldable LTree where
foldMap g (LBranches ts) = mconcat $ map (foldMap g) ts
foldMap g (LLeaf a) = g a