on master help sign in
start adjusting Example-OutOfTheTarpit to accomodate Atomable class
commitf9b0e23e4162db1e354b7274e89ce12c82ba3321 authorAgentM <agentm@themactionfaction.com> dateThu 23 Mar 2017, 19:54 (10 years ago) parent50f0e64
2 files changed+24−6
examples/out_of_the_tarpit.hs+20−5 src/lib/ProjectM36/Client.hs+4−1
examples/out_of_the_tarpit.hs+20−5
@@ -1,11 +1,14 @@
11-- the Out-of-the-Tarpit example in Haskell and Project:M36
2−{-# LANGUAGE DeriveAnyClass #-}
2+{-# LANGUAGE DeriveAnyClass, DeriveGeneric #-}
33import ProjectM36.Client
44import qualified Data.Map as M
55import qualified Data.Set as S
66import Data.Maybe
77import Control.Monad
88import Data.Monoid
9+import GHC.Generics
10+import Data.Binary
11+import Control.DeepSeq
912
1013addressAtomType :: AtomType
1114addressAtomType = TextAtomType
@@ -19,15 +22,27 @@ priceAtomType = DoubleAtomType
1922fileNameAtomType :: AtomType
2023fileNameAtomType = TextAtomType
2124
22−roomAtomType :: AtomType
23−roomAtomType = ConstructedAtomType "Room" M.empty
24−
25+data Room = Kitchen | Bathroom | LivingRoom
26+ deriving (Generic, Atomable, Eq, Show, Binary, NFData)
27+
28+roomAtomType :: AtomType
29+roomAtomType = toAtomType (undefined :: Room)
30+
31+data PriceBand = Low | Medium | High | Premium
32+ deriving (Generic, Atomable, Eq, Show, Binary, NFData)
33+
2534priceBandAtomType :: AtomType
26−priceBandAtomType = ConstructedAtomType "PriceBand" M.empty
35+priceBandAtomType = toAtomType (undefined :: PriceBand)
36+
37+data AreaCode = City | Suburban | Rural
38+ deriving (Generic, Atomable, Eq, Show, Binary, NFData)
2739
2840areaCodeAtomType :: AtomType
2941areaCodeAtomType = ConstructedAtomType "AreaCode" M.empty
3042
43+data SpeedBand = VeryFastBand | FastBand | MediumBand | SlowBand
44+ deriving (Generic, Atomable, Eq, Show, Binary, NFData)
45+
3146speedBandAtomType :: AtomType
3247speedBandAtomType = ConstructedAtomType "SpeedBand" M.empty
3348
src/lib/ProjectM36/Client.hs+4−1
@@ -74,10 +74,13 @@ module ProjectM36.Client
7474 AttributeName,
7575 RequestTimeoutException(..),
7676 RemoteProcessDiedException(..),
77− AtomType(..)) where
77+ AtomType(..),
78+ Atomable(..),
79+ ) where
7880import ProjectM36.Base hiding (inclusionDependencies) --defined in this module as well
7981import qualified ProjectM36.Base as B
8082import ProjectM36.Error
83+import ProjectM36.ConstructedAtom
8184import ProjectM36.StaticOptimizer
8285import ProjectM36.Key
8386import qualified ProjectM36.IsomorphicSchema as Schema