diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2011-07-12 03:08:19 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2011-07-12 03:08:19 +0200 |
commit | c918dde366a02ed4de26ea0c5e07a153d8f902bb (patch) | |
tree | ce8a24f997f1981d236bc7abc0227d6b0b997736 /lib/Phi/Panel.hs | |
parent | ade33320e5ea201a847bb9ee5522ee58b1cd8cb6 (diff) | |
download | phi-c918dde366a02ed4de26ea0c5e07a153d8f902bb.tar phi-c918dde366a02ed4de26ea0c5e07a153d8f902bb.zip |
Correctly divide into library and executable
Diffstat (limited to 'lib/Phi/Panel.hs')
-rw-r--r-- | lib/Phi/Panel.hs | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/Phi/Panel.hs b/lib/Phi/Panel.hs new file mode 100644 index 0000000..23b022f --- /dev/null +++ b/lib/Phi/Panel.hs @@ -0,0 +1,40 @@ +{-# LANGUAGE ExistentialQuantification #-} + +module Phi.Panel ( Panel(..) + , PanelClass(..) + , (<~>) + , separator + ) where + +import Data.Function + +class PanelClass a where + minSize :: a -> Int + + weight :: a -> Float + weight _ = 0 + +data Panel = forall a. PanelClass a => Panel a + +instance PanelClass Panel where + minSize (Panel p) = minSize p + weight (Panel p) = weight p + +data CompoundPanel = CompoundPanel Panel Panel + +instance PanelClass CompoundPanel where + minSize (CompoundPanel a b) = ((+) `on` minSize) a b + weight (CompoundPanel a b) = ((+) `on` weight) a b + +(<~>) :: Panel -> Panel -> Panel +a <~> b = Panel $ CompoundPanel a b + + +data Separator = Separator Int Float + +instance PanelClass Separator where + minSize (Separator s _) = s + weight (Separator _ w) = w + +separator :: Int -> Float -> Panel +separator s w = Panel $ Separator s w |