DataAna.hs revision df638d53c2d5fe5e80b943a58609c8936848ed82
ca5e921bbca4a90ad9adf7350bedcb7deb059e86Christian MaederModule : $Header$
e9458b1a7a19a63aa4c179f9ab20f4d50681c168Jens ElknerCopyright : (c) Christian Maeder and Uni Bremen 2002-2003
de6a40dbdd4712e5a9398b8519a59b1eaeab2f5aChristian MaederLicence : All rights reserved.
98890889ffb2e8f6f722b00e265a211f13b5a861Corneliu-Claudiu ProdescuMaintainer : hets@tzi.de
ca5e921bbca4a90ad9adf7350bedcb7deb059e86Christian MaederStability : provisional
3f69b6948966979163bdfe8331c38833d5d90ecdChristian MaederPortability : non-portable (MonadState)
ca5e921bbca4a90ad9adf7350bedcb7deb059e86Christian Maederanalyse alternatives of data types
ca5e921bbca4a90ad9adf7350bedcb7deb059e86Christian MaederanaAlts :: Type -> [Alternative] -> ReadR (ClassMap, TypeMap) [AltDefn]
a209694d7694b93e56927c6aacc3f5b9366fdb8fChristian MaederanaAlts dt alts = do l <- foldReadR (anaAlt dt) alts
ca5e921bbca4a90ad9adf7350bedcb7deb059e86Christian Maeder lift $ Result (checkUniqueness $ map
ca5e921bbca4a90ad9adf7350bedcb7deb059e86Christian Maeder ( \ (Construct i _ _ _) -> i) l)
4ef2a978e66e2246ff0b7f00c77deb7aabb28b8eChristian MaederanaAlt :: Type -> Alternative -> ReadR (ClassMap, TypeMap) AltDefn
ca5e921bbca4a90ad9adf7350bedcb7deb059e86Christian MaederanaAlt _ (Subtype ts ps) =
ca5e921bbca4a90ad9adf7350bedcb7deb059e86Christian Maeder do kts <- mapM anaType $ map ( \ t -> (star, t)) ts
ca5e921bbca4a90ad9adf7350bedcb7deb059e86Christian Maeder mapM ( \ (ki, ti) -> checkKindsR ti star ki) kts
616b72452ce5a75ade1a11ccc2c9671b3444558eChristian Maeder lift $ Result [Diag Warning "data subtype ignored" $ firstPos ts ps]
ca5e921bbca4a90ad9adf7350bedcb7deb059e86Christian MaederanaAlt dt (Constructor i cs p _) =
ca5e921bbca4a90ad9adf7350bedcb7deb059e86Christian Maeder do newCs <- mapM (anaComp i dt) $ zip cs $ map (:[]) [1..]
ca5e921bbca4a90ad9adf7350bedcb7deb059e86Christian Maeder let sels = concatMap snd newCs
ca5e921bbca4a90ad9adf7350bedcb7deb059e86Christian Maeder con = Construct i (map fst newCs) p sels
ca5e921bbca4a90ad9adf7350bedcb7deb059e86Christian Maeder -- check for disjoint selectors
ca5e921bbca4a90ad9adf7350bedcb7deb059e86Christian Maeder lift $ Result (checkUniqueness $ map ( \ (Select s _ _) -> s ) sels)
ca5e921bbca4a90ad9adf7350bedcb7deb059e86Christian MaedergetConstrType :: Type -> Partiality -> [Type] -> Type
ca5e921bbca4a90ad9adf7350bedcb7deb059e86Christian MaedergetConstrType dt p = addPartiality p .
ca5e921bbca4a90ad9adf7350bedcb7deb059e86Christian Maeder foldr ( \ c r -> FunType c FunArr r [] ) dt
740670de3c457d7571ef6f3fe9b60c2e25fb9902Christian MaederaddPartiality :: Partiality -> Type -> Type
740670de3c457d7571ef6f3fe9b60c2e25fb9902Christian MaederaddPartiality Total t = t
3d3889e0cefcdce9b3f43c53aaa201943ac2e895Jonathan von SchroederaddPartiality Partial t = makePartial t
2018084d6189a68640c516ca3e340d879f40f0acChristian MaedermakePartial :: Type -> Type
aa074a906c39b63c7177040378c0073dbac4e3baChristian MaedermakePartial t =