Commit ec068339 authored by Michael Hanus 's avatar Michael Hanus

Sensible type analysis added, bug fix in dependency type analysis

parent 36c3c5df
Sensible types analysis
The `SensibleType` analysis is a type analysis which checks
whether a type is sensible, i.e., whether there exists at least
one value of this type. This analysis associates to each type
constructor the following information:
* sensible, i.e., there is exists some value of this type
* parametric sensible, i.e., it is parametric type which is sensible
if all type arguments are instantiated with sensible types
* not sensible, i.e., there may be no values of this type
For instance, the list type constructor "[]" is sensible
and the pair type constructor "(,)" is parametric sensible.
For further examples, consider the following type declarations:
type Pair = (Int,Int)
data RTree a = RTree a [RTree a]
data ITree a = ITree a (ITree a)
type IntRTree = RTree Int
type IntITree = ITree Int
type ITreeRTree = RTree (ITree Int)
Then this analysis computes the following information:
Pair : sensible
RTree : parametric sensible
ITree : not sensible
IntRTree : sensible
IntITree : not sensible
ITreeRTree : not sensible
Note that function types are classified as not sensible since it is
not known whether some operation of this type exists.
......@@ -2,7 +2,7 @@
--- A few base functions for analysing type dependencies in FlatCurry programs.
--- @author Heiko Hoffmann, Michael Hanus
--- @version April 2013
--- @version Junes 2017
module CASS.FlatCurryDependency(dependsDirectlyOnTypes,callsDirectly) where
......@@ -22,10 +22,10 @@ dependsDirectlyOnTypes (TypeSyn _ _ _ typeExpr) = nub (tconsOf typeExpr)
tconsOf :: TypeExpr -> [QName]
tconsOf (TVar _) = []
tconsOf (FuncType a b) = tconsOf a ++ tconsOf b
tconsOf (TCons qName _) = [qName]
tconsOf (ForallType _ te) = tconsOf te
tconsOf (TVar _) = []
tconsOf (FuncType a b) = tconsOf a ++ tconsOf b
tconsOf (TCons qName texps) = qName : concatMap tconsOf texps
tconsOf (ForallType _ te) = tconsOf te
......@@ -41,6 +41,7 @@ import Analysis.RequiredValue
import qualified Analysis.RequiredValues as RVS
import Analysis.RightLinearity
import Analysis.RootReplaced
import Analysis.SensibleTypes
import Analysis.SolutionCompleteness
import Analysis.Termination
import Analysis.TotallyDefined
......@@ -70,6 +71,7 @@ registeredAnalysis =
,cassAnalysis "Higher-order constructors" hiOrdCons showOrder
,cassAnalysis "Higher-order functions" hiOrdFunc showOrder
,cassAnalysis "Productive operations" productivityAnalysis showProductivity
,cassAnalysis "Sensible types" sensibleType showSensible
,cassAnalysis "Sibling constructors" siblingCons showSibling
,cassAnalysis "Required value" reqValueAnalysis showAFType
,cassAnalysis "Required value sets" RVS.reqValueAnalysis RVS.showAFType
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment