{- |
    Module      :  $Header$
    Description :  Library to support meta-programming in Curry
    Copyright   :  Michael Hanus  , 2004
                   Martin Engelke , 2005
                   Björn Peemöller, 2015
                   Finn Teegen    , 2016
    License     :  BSD-3-clause

    Maintainer  :  bjp@informatik.uni-kiel.de
    Stability   :  experimental
    Portability :  portable

    This library contains a definition for representing Curry programs
    in Haskell by the type 'CurryProg' and I/O actions to read Curry programs
    and transform them into this abstract representation as well as
    write them to a file.

    Note that this defines a slightly new format for AbstractCurry
    in comparison to the first proposal of 2003.
-}
module Curry.AbstractCurry.Type
  ( CurryProg (..), MName, QName, CVisibility (..), CTVarIName
  , CDefaultDecl (..), CClassDecl (..), CInstanceDecl (..)
  , CTypeDecl (..), CConsDecl (..), CFieldDecl (..)
  , CConstraint, CContext (..), CTypeExpr (..), CQualTypeExpr (..)
  , COpDecl (..), CFixity (..), Arity, CFuncDecl (..), CRhs (..), CRule (..)
  , CLocalDecl (..), CVarIName, CExpr (..), CCaseType (..), CStatement (..)
  , CPattern (..), CLiteral (..), CField, version
  ) where

-- ---------------------------------------------------------------------------
-- Abstract syntax
-- ---------------------------------------------------------------------------

-- |Current version of AbstractCurry
version :: String
version :: String
version = "AbstractCurry 2.0"

-- |A module name.
type MName = String

-- |A qualified name.
-- In AbstractCurry all names are qualified to avoid name clashes.
-- The first component is the module name and the second component the
-- unqualified name as it occurs in the source program.
type QName = (MName, String)

-- |Data type to specify the visibility of various entities.
data CVisibility
  = Public    -- ^ exported entity
  | Private   -- ^ private entity
    deriving (CVisibility -> CVisibility -> Bool
(CVisibility -> CVisibility -> Bool)
-> (CVisibility -> CVisibility -> Bool) -> Eq CVisibility
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CVisibility -> CVisibility -> Bool
$c/= :: CVisibility -> CVisibility -> Bool
== :: CVisibility -> CVisibility -> Bool
$c== :: CVisibility -> CVisibility -> Bool
Eq, ReadPrec [CVisibility]
ReadPrec CVisibility
Int -> ReadS CVisibility
ReadS [CVisibility]
(Int -> ReadS CVisibility)
-> ReadS [CVisibility]
-> ReadPrec CVisibility
-> ReadPrec [CVisibility]
-> Read CVisibility
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CVisibility]
$creadListPrec :: ReadPrec [CVisibility]
readPrec :: ReadPrec CVisibility
$creadPrec :: ReadPrec CVisibility
readList :: ReadS [CVisibility]
$creadList :: ReadS [CVisibility]
readsPrec :: Int -> ReadS CVisibility
$creadsPrec :: Int -> ReadS CVisibility
Read, Int -> CVisibility -> ShowS
[CVisibility] -> ShowS
CVisibility -> String
(Int -> CVisibility -> ShowS)
-> (CVisibility -> String)
-> ([CVisibility] -> ShowS)
-> Show CVisibility
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CVisibility] -> ShowS
$cshowList :: [CVisibility] -> ShowS
show :: CVisibility -> String
$cshow :: CVisibility -> String
showsPrec :: Int -> CVisibility -> ShowS
$cshowsPrec :: Int -> CVisibility -> ShowS
Show)

-- |A Curry module in the intermediate form. A value of this type has the form
-- @
-- CurryProg modname imports dfltdecl clsdecls instdecls typedecls funcdecls opdecls
-- @
-- where
-- [@modname@]   Name of this module
-- [@imports@]   List of modules names that are imported
-- [@dfltdecl@]  Optional default declaration
-- [@clsdecls@]  Class declarations
-- [@instdecls@] Instance declarations
-- [@typedecls@] Type declarations
-- [@funcdecls@] Function declarations
-- [@opdecls@]   Operator precedence declarations
data CurryProg = CurryProg MName [MName] (Maybe CDefaultDecl) [CClassDecl]
                           [CInstanceDecl] [CTypeDecl] [CFuncDecl] [COpDecl]
    deriving (CurryProg -> CurryProg -> Bool
(CurryProg -> CurryProg -> Bool)
-> (CurryProg -> CurryProg -> Bool) -> Eq CurryProg
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CurryProg -> CurryProg -> Bool
$c/= :: CurryProg -> CurryProg -> Bool
== :: CurryProg -> CurryProg -> Bool
$c== :: CurryProg -> CurryProg -> Bool
Eq, ReadPrec [CurryProg]
ReadPrec CurryProg
Int -> ReadS CurryProg
ReadS [CurryProg]
(Int -> ReadS CurryProg)
-> ReadS [CurryProg]
-> ReadPrec CurryProg
-> ReadPrec [CurryProg]
-> Read CurryProg
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CurryProg]
$creadListPrec :: ReadPrec [CurryProg]
readPrec :: ReadPrec CurryProg
$creadPrec :: ReadPrec CurryProg
readList :: ReadS [CurryProg]
$creadList :: ReadS [CurryProg]
readsPrec :: Int -> ReadS CurryProg
$creadsPrec :: Int -> ReadS CurryProg
Read, Int -> CurryProg -> ShowS
[CurryProg] -> ShowS
CurryProg -> String
(Int -> CurryProg -> ShowS)
-> (CurryProg -> String)
-> ([CurryProg] -> ShowS)
-> Show CurryProg
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CurryProg] -> ShowS
$cshowList :: [CurryProg] -> ShowS
show :: CurryProg -> String
$cshow :: CurryProg -> String
showsPrec :: Int -> CurryProg -> ShowS
$cshowsPrec :: Int -> CurryProg -> ShowS
Show)

-- |Default declaration.
data CDefaultDecl = CDefaultDecl [CTypeExpr]
    deriving (CDefaultDecl -> CDefaultDecl -> Bool
(CDefaultDecl -> CDefaultDecl -> Bool)
-> (CDefaultDecl -> CDefaultDecl -> Bool) -> Eq CDefaultDecl
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CDefaultDecl -> CDefaultDecl -> Bool
$c/= :: CDefaultDecl -> CDefaultDecl -> Bool
== :: CDefaultDecl -> CDefaultDecl -> Bool
$c== :: CDefaultDecl -> CDefaultDecl -> Bool
Eq, ReadPrec [CDefaultDecl]
ReadPrec CDefaultDecl
Int -> ReadS CDefaultDecl
ReadS [CDefaultDecl]
(Int -> ReadS CDefaultDecl)
-> ReadS [CDefaultDecl]
-> ReadPrec CDefaultDecl
-> ReadPrec [CDefaultDecl]
-> Read CDefaultDecl
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CDefaultDecl]
$creadListPrec :: ReadPrec [CDefaultDecl]
readPrec :: ReadPrec CDefaultDecl
$creadPrec :: ReadPrec CDefaultDecl
readList :: ReadS [CDefaultDecl]
$creadList :: ReadS [CDefaultDecl]
readsPrec :: Int -> ReadS CDefaultDecl
$creadsPrec :: Int -> ReadS CDefaultDecl
Read, Int -> CDefaultDecl -> ShowS
[CDefaultDecl] -> ShowS
CDefaultDecl -> String
(Int -> CDefaultDecl -> ShowS)
-> (CDefaultDecl -> String)
-> ([CDefaultDecl] -> ShowS)
-> Show CDefaultDecl
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CDefaultDecl] -> ShowS
$cshowList :: [CDefaultDecl] -> ShowS
show :: CDefaultDecl -> String
$cshow :: CDefaultDecl -> String
showsPrec :: Int -> CDefaultDecl -> ShowS
$cshowsPrec :: Int -> CDefaultDecl -> ShowS
Show)

-- |Definitions of type classes.
-- A type class definition of the form
-- @
-- class cx => c a where { ...;f :: t;... }
-- @
-- is represented by the Curry term
-- @
-- (CClass c v cx tv [...(CFunc f ar v t [...,CRule r,...])...])
-- @
-- where @tv@ is the index of the type variable @a@ and @v@ is the
-- visibility of the type class resp. method.
-- /Note:/ The type variable indices are unique inside each class
--         declaration and are usually numbered from 0.
--         The methods' types share the type class' type variable index
--         as the class variable has to occur in a method's type signature.
--         The list of rules for a method's declaration may be empty if
--         no default implementation is provided. The arity @ar@ is
--         determined by a given default implementation or 0.
--         Regardless of whether typed or untyped abstract curry is generated,
--         the methods' declarations are always typed.
data CClassDecl = CClass QName CVisibility CContext CTVarIName [CFuncDecl]
    deriving (CClassDecl -> CClassDecl -> Bool
(CClassDecl -> CClassDecl -> Bool)
-> (CClassDecl -> CClassDecl -> Bool) -> Eq CClassDecl
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CClassDecl -> CClassDecl -> Bool
$c/= :: CClassDecl -> CClassDecl -> Bool
== :: CClassDecl -> CClassDecl -> Bool
$c== :: CClassDecl -> CClassDecl -> Bool
Eq, ReadPrec [CClassDecl]
ReadPrec CClassDecl
Int -> ReadS CClassDecl
ReadS [CClassDecl]
(Int -> ReadS CClassDecl)
-> ReadS [CClassDecl]
-> ReadPrec CClassDecl
-> ReadPrec [CClassDecl]
-> Read CClassDecl
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CClassDecl]
$creadListPrec :: ReadPrec [CClassDecl]
readPrec :: ReadPrec CClassDecl
$creadPrec :: ReadPrec CClassDecl
readList :: ReadS [CClassDecl]
$creadList :: ReadS [CClassDecl]
readsPrec :: Int -> ReadS CClassDecl
$creadsPrec :: Int -> ReadS CClassDecl
Read, Int -> CClassDecl -> ShowS
[CClassDecl] -> ShowS
CClassDecl -> String
(Int -> CClassDecl -> ShowS)
-> (CClassDecl -> String)
-> ([CClassDecl] -> ShowS)
-> Show CClassDecl
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CClassDecl] -> ShowS
$cshowList :: [CClassDecl] -> ShowS
show :: CClassDecl -> String
$cshow :: CClassDecl -> String
showsPrec :: Int -> CClassDecl -> ShowS
$cshowsPrec :: Int -> CClassDecl -> ShowS
Show)

-- |Definitions of instances.
-- An instance definition of the form
-- @
-- instance cx => c ty where { ...;fundecl;... }
-- @
-- is represented by the Curry term
-- @
-- (CInstance c cx ty [...fundecl...])
-- @
-- /Note:/ The type variable indices are unique inside each instance
--         declaration and are usually numbered from 0.
--         The methods' types use the instance's type variable indices
--         (if typed abstract curry is generated).
data CInstanceDecl = CInstance QName CContext CTypeExpr [CFuncDecl]
    deriving (CInstanceDecl -> CInstanceDecl -> Bool
(CInstanceDecl -> CInstanceDecl -> Bool)
-> (CInstanceDecl -> CInstanceDecl -> Bool) -> Eq CInstanceDecl
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CInstanceDecl -> CInstanceDecl -> Bool
$c/= :: CInstanceDecl -> CInstanceDecl -> Bool
== :: CInstanceDecl -> CInstanceDecl -> Bool
$c== :: CInstanceDecl -> CInstanceDecl -> Bool
Eq, ReadPrec [CInstanceDecl]
ReadPrec CInstanceDecl
Int -> ReadS CInstanceDecl
ReadS [CInstanceDecl]
(Int -> ReadS CInstanceDecl)
-> ReadS [CInstanceDecl]
-> ReadPrec CInstanceDecl
-> ReadPrec [CInstanceDecl]
-> Read CInstanceDecl
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CInstanceDecl]
$creadListPrec :: ReadPrec [CInstanceDecl]
readPrec :: ReadPrec CInstanceDecl
$creadPrec :: ReadPrec CInstanceDecl
readList :: ReadS [CInstanceDecl]
$creadList :: ReadS [CInstanceDecl]
readsPrec :: Int -> ReadS CInstanceDecl
$creadsPrec :: Int -> ReadS CInstanceDecl
Read, Int -> CInstanceDecl -> ShowS
[CInstanceDecl] -> ShowS
CInstanceDecl -> String
(Int -> CInstanceDecl -> ShowS)
-> (CInstanceDecl -> String)
-> ([CInstanceDecl] -> ShowS)
-> Show CInstanceDecl
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CInstanceDecl] -> ShowS
$cshowList :: [CInstanceDecl] -> ShowS
show :: CInstanceDecl -> String
$cshow :: CInstanceDecl -> String
showsPrec :: Int -> CInstanceDecl -> ShowS
$cshowsPrec :: Int -> CInstanceDecl -> ShowS
Show)

-- |Definitions of algebraic data types and type synonyms.
-- A data type definition of the form
-- @
-- data t x1...xn = ...| forall y1...ym . cx => c t1....tkc |...
--   deriving (d1,...,dp)
-- @
-- is represented by the Curry term
-- @
-- (CType t v [i1,...,in] [...(CCons [l1,...,lm] cx c kc v [t1,...,tkc])...]
--        [d1,...,dp])
-- @
-- where each @ij@ is the index of the type variable @xj@, each @lj@ is the
-- index of the existentially quantified type variable @yj@ and @v@ is the
-- visibility of the type resp. constructor.
-- /Note:/ The type variable indices are unique inside each type declaration
--         and are usually numbered from 0.
-- Thus, a data type declaration consists of the name of the data type,
-- a list of type parameters and a list of constructor declarations.
data CTypeDecl
    -- |algebraic data type
  = CType    QName CVisibility [CTVarIName] [CConsDecl] [QName]
    -- |type synonym
  | CTypeSyn QName CVisibility [CTVarIName] CTypeExpr
    -- |renaming type, may have only exactly one type expression
    -- in the constructor declaration and no existentially type variables and
    -- no context
  | CNewType QName CVisibility [CTVarIName] CConsDecl [QName]
    deriving (CTypeDecl -> CTypeDecl -> Bool
(CTypeDecl -> CTypeDecl -> Bool)
-> (CTypeDecl -> CTypeDecl -> Bool) -> Eq CTypeDecl
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CTypeDecl -> CTypeDecl -> Bool
$c/= :: CTypeDecl -> CTypeDecl -> Bool
== :: CTypeDecl -> CTypeDecl -> Bool
$c== :: CTypeDecl -> CTypeDecl -> Bool
Eq, ReadPrec [CTypeDecl]
ReadPrec CTypeDecl
Int -> ReadS CTypeDecl
ReadS [CTypeDecl]
(Int -> ReadS CTypeDecl)
-> ReadS [CTypeDecl]
-> ReadPrec CTypeDecl
-> ReadPrec [CTypeDecl]
-> Read CTypeDecl
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CTypeDecl]
$creadListPrec :: ReadPrec [CTypeDecl]
readPrec :: ReadPrec CTypeDecl
$creadPrec :: ReadPrec CTypeDecl
readList :: ReadS [CTypeDecl]
$creadList :: ReadS [CTypeDecl]
readsPrec :: Int -> ReadS CTypeDecl
$creadsPrec :: Int -> ReadS CTypeDecl
Read, Int -> CTypeDecl -> ShowS
[CTypeDecl] -> ShowS
CTypeDecl -> String
(Int -> CTypeDecl -> ShowS)
-> (CTypeDecl -> String)
-> ([CTypeDecl] -> ShowS)
-> Show CTypeDecl
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CTypeDecl] -> ShowS
$cshowList :: [CTypeDecl] -> ShowS
show :: CTypeDecl -> String
$cshow :: CTypeDecl -> String
showsPrec :: Int -> CTypeDecl -> ShowS
$cshowsPrec :: Int -> CTypeDecl -> ShowS
Show)

-- |The type for representing type variables.
-- They are represented by @(i,n)@ where @i@ is a type variable index
-- which is unique inside a function and @n@ is a name (if possible,
-- the name written in the source program).
type CTVarIName = (Int, String)

-- TODO: Remove context and existential quantified type variables.
-- |A constructor declaration consists of a list of existentially
-- quantified type variables, a context, the name of the constructor
-- and a list of the argument types of the constructor.
-- The arity equals the number of types.
data CConsDecl
  = CCons   [CTVarIName] CContext QName CVisibility [CTypeExpr]
  | CRecord [CTVarIName] CContext QName CVisibility [CFieldDecl]
    deriving (CConsDecl -> CConsDecl -> Bool
(CConsDecl -> CConsDecl -> Bool)
-> (CConsDecl -> CConsDecl -> Bool) -> Eq CConsDecl
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CConsDecl -> CConsDecl -> Bool
$c/= :: CConsDecl -> CConsDecl -> Bool
== :: CConsDecl -> CConsDecl -> Bool
$c== :: CConsDecl -> CConsDecl -> Bool
Eq, ReadPrec [CConsDecl]
ReadPrec CConsDecl
Int -> ReadS CConsDecl
ReadS [CConsDecl]
(Int -> ReadS CConsDecl)
-> ReadS [CConsDecl]
-> ReadPrec CConsDecl
-> ReadPrec [CConsDecl]
-> Read CConsDecl
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CConsDecl]
$creadListPrec :: ReadPrec [CConsDecl]
readPrec :: ReadPrec CConsDecl
$creadPrec :: ReadPrec CConsDecl
readList :: ReadS [CConsDecl]
$creadList :: ReadS [CConsDecl]
readsPrec :: Int -> ReadS CConsDecl
$creadsPrec :: Int -> ReadS CConsDecl
Read, Int -> CConsDecl -> ShowS
[CConsDecl] -> ShowS
CConsDecl -> String
(Int -> CConsDecl -> ShowS)
-> (CConsDecl -> String)
-> ([CConsDecl] -> ShowS)
-> Show CConsDecl
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CConsDecl] -> ShowS
$cshowList :: [CConsDecl] -> ShowS
show :: CConsDecl -> String
$cshow :: CConsDecl -> String
showsPrec :: Int -> CConsDecl -> ShowS
$cshowsPrec :: Int -> CConsDecl -> ShowS
Show)

-- |A record field declaration consists of the name of the
-- the label, the visibility and its corresponding type.
data CFieldDecl = CField QName CVisibility CTypeExpr
  deriving (CFieldDecl -> CFieldDecl -> Bool
(CFieldDecl -> CFieldDecl -> Bool)
-> (CFieldDecl -> CFieldDecl -> Bool) -> Eq CFieldDecl
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CFieldDecl -> CFieldDecl -> Bool
$c/= :: CFieldDecl -> CFieldDecl -> Bool
== :: CFieldDecl -> CFieldDecl -> Bool
$c== :: CFieldDecl -> CFieldDecl -> Bool
Eq, ReadPrec [CFieldDecl]
ReadPrec CFieldDecl
Int -> ReadS CFieldDecl
ReadS [CFieldDecl]
(Int -> ReadS CFieldDecl)
-> ReadS [CFieldDecl]
-> ReadPrec CFieldDecl
-> ReadPrec [CFieldDecl]
-> Read CFieldDecl
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CFieldDecl]
$creadListPrec :: ReadPrec [CFieldDecl]
readPrec :: ReadPrec CFieldDecl
$creadPrec :: ReadPrec CFieldDecl
readList :: ReadS [CFieldDecl]
$creadList :: ReadS [CFieldDecl]
readsPrec :: Int -> ReadS CFieldDecl
$creadsPrec :: Int -> ReadS CFieldDecl
Read, Int -> CFieldDecl -> ShowS
[CFieldDecl] -> ShowS
CFieldDecl -> String
(Int -> CFieldDecl -> ShowS)
-> (CFieldDecl -> String)
-> ([CFieldDecl] -> ShowS)
-> Show CFieldDecl
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CFieldDecl] -> ShowS
$cshowList :: [CFieldDecl] -> ShowS
show :: CFieldDecl -> String
$cshow :: CFieldDecl -> String
showsPrec :: Int -> CFieldDecl -> ShowS
$cshowsPrec :: Int -> CFieldDecl -> ShowS
Show)

-- |The type for representing a class constraint.
type CConstraint = (QName, CTypeExpr)

-- |The type for representing a context.
data CContext = CContext [CConstraint]
  deriving (CContext -> CContext -> Bool
(CContext -> CContext -> Bool)
-> (CContext -> CContext -> Bool) -> Eq CContext
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CContext -> CContext -> Bool
$c/= :: CContext -> CContext -> Bool
== :: CContext -> CContext -> Bool
$c== :: CContext -> CContext -> Bool
Eq, ReadPrec [CContext]
ReadPrec CContext
Int -> ReadS CContext
ReadS [CContext]
(Int -> ReadS CContext)
-> ReadS [CContext]
-> ReadPrec CContext
-> ReadPrec [CContext]
-> Read CContext
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CContext]
$creadListPrec :: ReadPrec [CContext]
readPrec :: ReadPrec CContext
$creadPrec :: ReadPrec CContext
readList :: ReadS [CContext]
$creadList :: ReadS [CContext]
readsPrec :: Int -> ReadS CContext
$creadsPrec :: Int -> ReadS CContext
Read, Int -> CContext -> ShowS
[CContext] -> ShowS
CContext -> String
(Int -> CContext -> ShowS)
-> (CContext -> String) -> ([CContext] -> ShowS) -> Show CContext
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CContext] -> ShowS
$cshowList :: [CContext] -> ShowS
show :: CContext -> String
$cshow :: CContext -> String
showsPrec :: Int -> CContext -> ShowS
$cshowsPrec :: Int -> CContext -> ShowS
Show)

-- |Type expression.
-- A type expression is either a type variable, a function type,
-- a type constructor or a type application.
data CTypeExpr
    -- |Type variable
  = CTVar CTVarIName
    -- |Function type @t1 -> t2@
  | CFuncType CTypeExpr CTypeExpr
    -- |Type constructor
  | CTCons QName
    -- |Type application
  | CTApply CTypeExpr CTypeExpr
    deriving (CTypeExpr -> CTypeExpr -> Bool
(CTypeExpr -> CTypeExpr -> Bool)
-> (CTypeExpr -> CTypeExpr -> Bool) -> Eq CTypeExpr
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CTypeExpr -> CTypeExpr -> Bool
$c/= :: CTypeExpr -> CTypeExpr -> Bool
== :: CTypeExpr -> CTypeExpr -> Bool
$c== :: CTypeExpr -> CTypeExpr -> Bool
Eq, ReadPrec [CTypeExpr]
ReadPrec CTypeExpr
Int -> ReadS CTypeExpr
ReadS [CTypeExpr]
(Int -> ReadS CTypeExpr)
-> ReadS [CTypeExpr]
-> ReadPrec CTypeExpr
-> ReadPrec [CTypeExpr]
-> Read CTypeExpr
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CTypeExpr]
$creadListPrec :: ReadPrec [CTypeExpr]
readPrec :: ReadPrec CTypeExpr
$creadPrec :: ReadPrec CTypeExpr
readList :: ReadS [CTypeExpr]
$creadList :: ReadS [CTypeExpr]
readsPrec :: Int -> ReadS CTypeExpr
$creadsPrec :: Int -> ReadS CTypeExpr
Read, Int -> CTypeExpr -> ShowS
[CTypeExpr] -> ShowS
CTypeExpr -> String
(Int -> CTypeExpr -> ShowS)
-> (CTypeExpr -> String)
-> ([CTypeExpr] -> ShowS)
-> Show CTypeExpr
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CTypeExpr] -> ShowS
$cshowList :: [CTypeExpr] -> ShowS
show :: CTypeExpr -> String
$cshow :: CTypeExpr -> String
showsPrec :: Int -> CTypeExpr -> ShowS
$cshowsPrec :: Int -> CTypeExpr -> ShowS
Show)

-- |Qualified type expression.
data CQualTypeExpr = CQualType CContext CTypeExpr
    deriving (CQualTypeExpr -> CQualTypeExpr -> Bool
(CQualTypeExpr -> CQualTypeExpr -> Bool)
-> (CQualTypeExpr -> CQualTypeExpr -> Bool) -> Eq CQualTypeExpr
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CQualTypeExpr -> CQualTypeExpr -> Bool
$c/= :: CQualTypeExpr -> CQualTypeExpr -> Bool
== :: CQualTypeExpr -> CQualTypeExpr -> Bool
$c== :: CQualTypeExpr -> CQualTypeExpr -> Bool
Eq, ReadPrec [CQualTypeExpr]
ReadPrec CQualTypeExpr
Int -> ReadS CQualTypeExpr
ReadS [CQualTypeExpr]
(Int -> ReadS CQualTypeExpr)
-> ReadS [CQualTypeExpr]
-> ReadPrec CQualTypeExpr
-> ReadPrec [CQualTypeExpr]
-> Read CQualTypeExpr
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CQualTypeExpr]
$creadListPrec :: ReadPrec [CQualTypeExpr]
readPrec :: ReadPrec CQualTypeExpr
$creadPrec :: ReadPrec CQualTypeExpr
readList :: ReadS [CQualTypeExpr]
$creadList :: ReadS [CQualTypeExpr]
readsPrec :: Int -> ReadS CQualTypeExpr
$creadsPrec :: Int -> ReadS CQualTypeExpr
Read, Int -> CQualTypeExpr -> ShowS
[CQualTypeExpr] -> ShowS
CQualTypeExpr -> String
(Int -> CQualTypeExpr -> ShowS)
-> (CQualTypeExpr -> String)
-> ([CQualTypeExpr] -> ShowS)
-> Show CQualTypeExpr
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CQualTypeExpr] -> ShowS
$cshowList :: [CQualTypeExpr] -> ShowS
show :: CQualTypeExpr -> String
$cshow :: CQualTypeExpr -> String
showsPrec :: Int -> CQualTypeExpr -> ShowS
$cshowsPrec :: Int -> CQualTypeExpr -> ShowS
Show)

-- |Labeled record fields
type CField a = (QName, a)

-- |Operator precedence declaration.
-- An operator precedence declaration @fix p n@ in Curry corresponds to the
-- AbstractCurry term @(COp n fix p)@.
data COpDecl = COp QName CFixity Int
    deriving (COpDecl -> COpDecl -> Bool
(COpDecl -> COpDecl -> Bool)
-> (COpDecl -> COpDecl -> Bool) -> Eq COpDecl
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: COpDecl -> COpDecl -> Bool
$c/= :: COpDecl -> COpDecl -> Bool
== :: COpDecl -> COpDecl -> Bool
$c== :: COpDecl -> COpDecl -> Bool
Eq, ReadPrec [COpDecl]
ReadPrec COpDecl
Int -> ReadS COpDecl
ReadS [COpDecl]
(Int -> ReadS COpDecl)
-> ReadS [COpDecl]
-> ReadPrec COpDecl
-> ReadPrec [COpDecl]
-> Read COpDecl
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [COpDecl]
$creadListPrec :: ReadPrec [COpDecl]
readPrec :: ReadPrec COpDecl
$creadPrec :: ReadPrec COpDecl
readList :: ReadS [COpDecl]
$creadList :: ReadS [COpDecl]
readsPrec :: Int -> ReadS COpDecl
$creadsPrec :: Int -> ReadS COpDecl
Read, Int -> COpDecl -> ShowS
[COpDecl] -> ShowS
COpDecl -> String
(Int -> COpDecl -> ShowS)
-> (COpDecl -> String) -> ([COpDecl] -> ShowS) -> Show COpDecl
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [COpDecl] -> ShowS
$cshowList :: [COpDecl] -> ShowS
show :: COpDecl -> String
$cshow :: COpDecl -> String
showsPrec :: Int -> COpDecl -> ShowS
$cshowsPrec :: Int -> COpDecl -> ShowS
Show)

-- |Fixity declarations of infix operators
data CFixity
  = CInfixOp  -- ^ non-associative infix operator
  | CInfixlOp -- ^ left-associative infix operator
  | CInfixrOp -- ^ right-associative infix operator
    deriving (CFixity -> CFixity -> Bool
(CFixity -> CFixity -> Bool)
-> (CFixity -> CFixity -> Bool) -> Eq CFixity
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CFixity -> CFixity -> Bool
$c/= :: CFixity -> CFixity -> Bool
== :: CFixity -> CFixity -> Bool
$c== :: CFixity -> CFixity -> Bool
Eq, ReadPrec [CFixity]
ReadPrec CFixity
Int -> ReadS CFixity
ReadS [CFixity]
(Int -> ReadS CFixity)
-> ReadS [CFixity]
-> ReadPrec CFixity
-> ReadPrec [CFixity]
-> Read CFixity
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CFixity]
$creadListPrec :: ReadPrec [CFixity]
readPrec :: ReadPrec CFixity
$creadPrec :: ReadPrec CFixity
readList :: ReadS [CFixity]
$creadList :: ReadS [CFixity]
readsPrec :: Int -> ReadS CFixity
$creadsPrec :: Int -> ReadS CFixity
Read, Int -> CFixity -> ShowS
[CFixity] -> ShowS
CFixity -> String
(Int -> CFixity -> ShowS)
-> (CFixity -> String) -> ([CFixity] -> ShowS) -> Show CFixity
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CFixity] -> ShowS
$cshowList :: [CFixity] -> ShowS
show :: CFixity -> String
$cshow :: CFixity -> String
showsPrec :: Int -> CFixity -> ShowS
$cshowsPrec :: Int -> CFixity -> ShowS
Show)

-- |Function arity
type Arity = Int

-- |Data type for representing function declarations.
-- A function declaration in FlatCurry is a term of the form
-- @
-- (CFunc name arity visibility type (CRules eval [CRule rule1,...,rulek]))
-- @
-- and represents the function @name@ with definition
-- @
-- name :: type
-- rule1
-- ...
-- rulek
-- @
-- /Note:/ The variable indices are unique inside each rule.
-- External functions are represented as
-- @
-- (CFunc name arity type (CExternal s))
-- @
-- where s is the external name associated to this function.
-- Thus, a function declaration consists of the name, arity, type, and
-- a list of rules.
-- If the list of rules is empty, the function is considered
-- to be externally defined.
data CFuncDecl = CFunc QName Arity CVisibility CQualTypeExpr [CRule]
    deriving (CFuncDecl -> CFuncDecl -> Bool
(CFuncDecl -> CFuncDecl -> Bool)
-> (CFuncDecl -> CFuncDecl -> Bool) -> Eq CFuncDecl
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CFuncDecl -> CFuncDecl -> Bool
$c/= :: CFuncDecl -> CFuncDecl -> Bool
== :: CFuncDecl -> CFuncDecl -> Bool
$c== :: CFuncDecl -> CFuncDecl -> Bool
Eq, ReadPrec [CFuncDecl]
ReadPrec CFuncDecl
Int -> ReadS CFuncDecl
ReadS [CFuncDecl]
(Int -> ReadS CFuncDecl)
-> ReadS [CFuncDecl]
-> ReadPrec CFuncDecl
-> ReadPrec [CFuncDecl]
-> Read CFuncDecl
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CFuncDecl]
$creadListPrec :: ReadPrec [CFuncDecl]
readPrec :: ReadPrec CFuncDecl
$creadPrec :: ReadPrec CFuncDecl
readList :: ReadS [CFuncDecl]
$creadList :: ReadS [CFuncDecl]
readsPrec :: Int -> ReadS CFuncDecl
$creadsPrec :: Int -> ReadS CFuncDecl
Read, Int -> CFuncDecl -> ShowS
[CFuncDecl] -> ShowS
CFuncDecl -> String
(Int -> CFuncDecl -> ShowS)
-> (CFuncDecl -> String)
-> ([CFuncDecl] -> ShowS)
-> Show CFuncDecl
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CFuncDecl] -> ShowS
$cshowList :: [CFuncDecl] -> ShowS
show :: CFuncDecl -> String
$cshow :: CFuncDecl -> String
showsPrec :: Int -> CFuncDecl -> ShowS
$cshowsPrec :: Int -> CFuncDecl -> ShowS
Show)

-- |The general form of a function rule. It consists of a list of patterns
-- (left-hand side), a list of guards (@success@ if not present in the
-- source text) with their corresponding right-hand sides, and
-- a list of local declarations.
data CRule = CRule [CPattern] CRhs
    deriving (CRule -> CRule -> Bool
(CRule -> CRule -> Bool) -> (CRule -> CRule -> Bool) -> Eq CRule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CRule -> CRule -> Bool
$c/= :: CRule -> CRule -> Bool
== :: CRule -> CRule -> Bool
$c== :: CRule -> CRule -> Bool
Eq, ReadPrec [CRule]
ReadPrec CRule
Int -> ReadS CRule
ReadS [CRule]
(Int -> ReadS CRule)
-> ReadS [CRule]
-> ReadPrec CRule
-> ReadPrec [CRule]
-> Read CRule
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CRule]
$creadListPrec :: ReadPrec [CRule]
readPrec :: ReadPrec CRule
$creadPrec :: ReadPrec CRule
readList :: ReadS [CRule]
$creadList :: ReadS [CRule]
readsPrec :: Int -> ReadS CRule
$creadsPrec :: Int -> ReadS CRule
Read, Int -> CRule -> ShowS
[CRule] -> ShowS
CRule -> String
(Int -> CRule -> ShowS)
-> (CRule -> String) -> ([CRule] -> ShowS) -> Show CRule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CRule] -> ShowS
$cshowList :: [CRule] -> ShowS
show :: CRule -> String
$cshow :: CRule -> String
showsPrec :: Int -> CRule -> ShowS
$cshowsPrec :: Int -> CRule -> ShowS
Show)

-- |Right-hand-side of a 'CRule' or an @case@ expression
data CRhs
  = CSimpleRhs  CExpr            [CLocalDecl] -- @expr where decls@
  | CGuardedRhs [(CExpr, CExpr)] [CLocalDecl] -- @| cond = expr where decls@
    deriving (CRhs -> CRhs -> Bool
(CRhs -> CRhs -> Bool) -> (CRhs -> CRhs -> Bool) -> Eq CRhs
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CRhs -> CRhs -> Bool
$c/= :: CRhs -> CRhs -> Bool
== :: CRhs -> CRhs -> Bool
$c== :: CRhs -> CRhs -> Bool
Eq, ReadPrec [CRhs]
ReadPrec CRhs
Int -> ReadS CRhs
ReadS [CRhs]
(Int -> ReadS CRhs)
-> ReadS [CRhs] -> ReadPrec CRhs -> ReadPrec [CRhs] -> Read CRhs
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CRhs]
$creadListPrec :: ReadPrec [CRhs]
readPrec :: ReadPrec CRhs
$creadPrec :: ReadPrec CRhs
readList :: ReadS [CRhs]
$creadList :: ReadS [CRhs]
readsPrec :: Int -> ReadS CRhs
$creadsPrec :: Int -> ReadS CRhs
Read, Int -> CRhs -> ShowS
[CRhs] -> ShowS
CRhs -> String
(Int -> CRhs -> ShowS)
-> (CRhs -> String) -> ([CRhs] -> ShowS) -> Show CRhs
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CRhs] -> ShowS
$cshowList :: [CRhs] -> ShowS
show :: CRhs -> String
$cshow :: CRhs -> String
showsPrec :: Int -> CRhs -> ShowS
$cshowsPrec :: Int -> CRhs -> ShowS
Show)

-- | Local (let/where) declarations
data CLocalDecl
  = CLocalFunc CFuncDecl     -- ^ local function declaration
  | CLocalPat  CPattern CRhs -- ^ local pattern declaration
  | CLocalVars [CVarIName]   -- ^ local free variable declarations
    deriving (CLocalDecl -> CLocalDecl -> Bool
(CLocalDecl -> CLocalDecl -> Bool)
-> (CLocalDecl -> CLocalDecl -> Bool) -> Eq CLocalDecl
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CLocalDecl -> CLocalDecl -> Bool
$c/= :: CLocalDecl -> CLocalDecl -> Bool
== :: CLocalDecl -> CLocalDecl -> Bool
$c== :: CLocalDecl -> CLocalDecl -> Bool
Eq, ReadPrec [CLocalDecl]
ReadPrec CLocalDecl
Int -> ReadS CLocalDecl
ReadS [CLocalDecl]
(Int -> ReadS CLocalDecl)
-> ReadS [CLocalDecl]
-> ReadPrec CLocalDecl
-> ReadPrec [CLocalDecl]
-> Read CLocalDecl
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CLocalDecl]
$creadListPrec :: ReadPrec [CLocalDecl]
readPrec :: ReadPrec CLocalDecl
$creadPrec :: ReadPrec CLocalDecl
readList :: ReadS [CLocalDecl]
$creadList :: ReadS [CLocalDecl]
readsPrec :: Int -> ReadS CLocalDecl
$creadsPrec :: Int -> ReadS CLocalDecl
Read, Int -> CLocalDecl -> ShowS
[CLocalDecl] -> ShowS
CLocalDecl -> String
(Int -> CLocalDecl -> ShowS)
-> (CLocalDecl -> String)
-> ([CLocalDecl] -> ShowS)
-> Show CLocalDecl
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CLocalDecl] -> ShowS
$cshowList :: [CLocalDecl] -> ShowS
show :: CLocalDecl -> String
$cshow :: CLocalDecl -> String
showsPrec :: Int -> CLocalDecl -> ShowS
$cshowsPrec :: Int -> CLocalDecl -> ShowS
Show)

-- |Variable names.
-- Object variables occurring in expressions are represented by @(Var i)@
-- where @i@ is a variable index.
type CVarIName = (Int, String)

-- |Pattern expressions.
data CPattern
    -- |pattern variable (unique index / name)
  = CPVar CVarIName
    -- |literal (Integer/Float/Char constant)
  | CPLit CLiteral
    -- |application @(m.c e1 ... en)@ of n-ary constructor @m.c@
    --  (@CPComb (m,c) [e1,...,en]@)
  | CPComb QName [CPattern]
    -- |as-pattern (extended Curry)
  | CPAs CVarIName CPattern
    -- |functional pattern (extended Curry)
  | CPFuncComb QName [CPattern]
    -- |lazy pattern (extended Curry)
  | CPLazy CPattern
    -- |record pattern (extended curry)
  | CPRecord QName [CField CPattern]
    deriving (CPattern -> CPattern -> Bool
(CPattern -> CPattern -> Bool)
-> (CPattern -> CPattern -> Bool) -> Eq CPattern
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CPattern -> CPattern -> Bool
$c/= :: CPattern -> CPattern -> Bool
== :: CPattern -> CPattern -> Bool
$c== :: CPattern -> CPattern -> Bool
Eq, ReadPrec [CPattern]
ReadPrec CPattern
Int -> ReadS CPattern
ReadS [CPattern]
(Int -> ReadS CPattern)
-> ReadS [CPattern]
-> ReadPrec CPattern
-> ReadPrec [CPattern]
-> Read CPattern
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CPattern]
$creadListPrec :: ReadPrec [CPattern]
readPrec :: ReadPrec CPattern
$creadPrec :: ReadPrec CPattern
readList :: ReadS [CPattern]
$creadList :: ReadS [CPattern]
readsPrec :: Int -> ReadS CPattern
$creadsPrec :: Int -> ReadS CPattern
Read, Int -> CPattern -> ShowS
[CPattern] -> ShowS
CPattern -> String
(Int -> CPattern -> ShowS)
-> (CPattern -> String) -> ([CPattern] -> ShowS) -> Show CPattern
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CPattern] -> ShowS
$cshowList :: [CPattern] -> ShowS
show :: CPattern -> String
$cshow :: CPattern -> String
showsPrec :: Int -> CPattern -> ShowS
$cshowsPrec :: Int -> CPattern -> ShowS
Show)

-- | Curry expressions.
data CExpr
    -- |variable (unique index / name)
  = CVar       CVarIName
    -- |literal (Integer/Float/Char/String constant)
  | CLit       CLiteral
    -- |a defined symbol with module and name, i.e., a function or a constructor
  | CSymbol    QName
    -- |application (e1 e2)
  | CApply     CExpr CExpr
    -- |lambda abstraction
  | CLambda    [CPattern] CExpr
    -- |local let declarations
  | CLetDecl   [CLocalDecl] CExpr
    -- |do block
  | CDoExpr    [CStatement]
    -- |list comprehension
  | CListComp  CExpr [CStatement]
    -- |case expression
  | CCase      CCaseType CExpr [(CPattern, CRhs)]
    -- |typed expression
  | CTyped     CExpr CQualTypeExpr
    -- |record construction (extended Curry)
  | CRecConstr QName [CField CExpr]
    -- |record update (extended Curry)
  | CRecUpdate CExpr [CField CExpr]
    deriving (CExpr -> CExpr -> Bool
(CExpr -> CExpr -> Bool) -> (CExpr -> CExpr -> Bool) -> Eq CExpr
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CExpr -> CExpr -> Bool
$c/= :: CExpr -> CExpr -> Bool
== :: CExpr -> CExpr -> Bool
$c== :: CExpr -> CExpr -> Bool
Eq, ReadPrec [CExpr]
ReadPrec CExpr
Int -> ReadS CExpr
ReadS [CExpr]
(Int -> ReadS CExpr)
-> ReadS [CExpr]
-> ReadPrec CExpr
-> ReadPrec [CExpr]
-> Read CExpr
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CExpr]
$creadListPrec :: ReadPrec [CExpr]
readPrec :: ReadPrec CExpr
$creadPrec :: ReadPrec CExpr
readList :: ReadS [CExpr]
$creadList :: ReadS [CExpr]
readsPrec :: Int -> ReadS CExpr
$creadsPrec :: Int -> ReadS CExpr
Read, Int -> CExpr -> ShowS
[CExpr] -> ShowS
CExpr -> String
(Int -> CExpr -> ShowS)
-> (CExpr -> String) -> ([CExpr] -> ShowS) -> Show CExpr
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CExpr] -> ShowS
$cshowList :: [CExpr] -> ShowS
show :: CExpr -> String
$cshow :: CExpr -> String
showsPrec :: Int -> CExpr -> ShowS
$cshowsPrec :: Int -> CExpr -> ShowS
Show)

-- |Literals occurring in an expression or a pattern,
-- either an integer, a float, a character, or a string constant.
-- /Note:/ The constructor definition of 'CIntc' differs from the original
-- PAKCS definition. It uses Haskell type 'Integer' instead of 'Int'
-- to provide an unlimited range of integer numbers. Furthermore,
-- float values are represented with Haskell type 'Double' instead of
-- 'Float' to gain double precision.
data CLiteral
  = CIntc    Integer -- ^ Int literal
  | CFloatc  Double  -- ^ Float literal
  | CCharc   Char    -- ^ Char literal
  | CStringc String  -- ^ String literal
    deriving (CLiteral -> CLiteral -> Bool
(CLiteral -> CLiteral -> Bool)
-> (CLiteral -> CLiteral -> Bool) -> Eq CLiteral
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CLiteral -> CLiteral -> Bool
$c/= :: CLiteral -> CLiteral -> Bool
== :: CLiteral -> CLiteral -> Bool
$c== :: CLiteral -> CLiteral -> Bool
Eq, ReadPrec [CLiteral]
ReadPrec CLiteral
Int -> ReadS CLiteral
ReadS [CLiteral]
(Int -> ReadS CLiteral)
-> ReadS [CLiteral]
-> ReadPrec CLiteral
-> ReadPrec [CLiteral]
-> Read CLiteral
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CLiteral]
$creadListPrec :: ReadPrec [CLiteral]
readPrec :: ReadPrec CLiteral
$creadPrec :: ReadPrec CLiteral
readList :: ReadS [CLiteral]
$creadList :: ReadS [CLiteral]
readsPrec :: Int -> ReadS CLiteral
$creadsPrec :: Int -> ReadS CLiteral
Read, Int -> CLiteral -> ShowS
[CLiteral] -> ShowS
CLiteral -> String
(Int -> CLiteral -> ShowS)
-> (CLiteral -> String) -> ([CLiteral] -> ShowS) -> Show CLiteral
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CLiteral] -> ShowS
$cshowList :: [CLiteral] -> ShowS
show :: CLiteral -> String
$cshow :: CLiteral -> String
showsPrec :: Int -> CLiteral -> ShowS
$cshowsPrec :: Int -> CLiteral -> ShowS
Show)

-- |Statements in do expressions and list comprehensions.
data CStatement
  = CSExpr CExpr          -- ^ an expression (I/O action or boolean)
  | CSPat  CPattern CExpr -- ^ a pattern definition
  | CSLet  [CLocalDecl]   -- ^ a local let declaration
    deriving (CStatement -> CStatement -> Bool
(CStatement -> CStatement -> Bool)
-> (CStatement -> CStatement -> Bool) -> Eq CStatement
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CStatement -> CStatement -> Bool
$c/= :: CStatement -> CStatement -> Bool
== :: CStatement -> CStatement -> Bool
$c== :: CStatement -> CStatement -> Bool
Eq, ReadPrec [CStatement]
ReadPrec CStatement
Int -> ReadS CStatement
ReadS [CStatement]
(Int -> ReadS CStatement)
-> ReadS [CStatement]
-> ReadPrec CStatement
-> ReadPrec [CStatement]
-> Read CStatement
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CStatement]
$creadListPrec :: ReadPrec [CStatement]
readPrec :: ReadPrec CStatement
$creadPrec :: ReadPrec CStatement
readList :: ReadS [CStatement]
$creadList :: ReadS [CStatement]
readsPrec :: Int -> ReadS CStatement
$creadsPrec :: Int -> ReadS CStatement
Read, Int -> CStatement -> ShowS
[CStatement] -> ShowS
CStatement -> String
(Int -> CStatement -> ShowS)
-> (CStatement -> String)
-> ([CStatement] -> ShowS)
-> Show CStatement
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CStatement] -> ShowS
$cshowList :: [CStatement] -> ShowS
show :: CStatement -> String
$cshow :: CStatement -> String
showsPrec :: Int -> CStatement -> ShowS
$cshowsPrec :: Int -> CStatement -> ShowS
Show)

-- |Type of case expressions
data CCaseType
  = CRigid -- ^ rigid case expression
  | CFlex  -- ^ flexible case expression
    deriving (CCaseType -> CCaseType -> Bool
(CCaseType -> CCaseType -> Bool)
-> (CCaseType -> CCaseType -> Bool) -> Eq CCaseType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CCaseType -> CCaseType -> Bool
$c/= :: CCaseType -> CCaseType -> Bool
== :: CCaseType -> CCaseType -> Bool
$c== :: CCaseType -> CCaseType -> Bool
Eq, ReadPrec [CCaseType]
ReadPrec CCaseType
Int -> ReadS CCaseType
ReadS [CCaseType]
(Int -> ReadS CCaseType)
-> ReadS [CCaseType]
-> ReadPrec CCaseType
-> ReadPrec [CCaseType]
-> Read CCaseType
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CCaseType]
$creadListPrec :: ReadPrec [CCaseType]
readPrec :: ReadPrec CCaseType
$creadPrec :: ReadPrec CCaseType
readList :: ReadS [CCaseType]
$creadList :: ReadS [CCaseType]
readsPrec :: Int -> ReadS CCaseType
$creadsPrec :: Int -> ReadS CCaseType
Read, Int -> CCaseType -> ShowS
[CCaseType] -> ShowS
CCaseType -> String
(Int -> CCaseType -> ShowS)
-> (CCaseType -> String)
-> ([CCaseType] -> ShowS)
-> Show CCaseType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CCaseType] -> ShowS
$cshowList :: [CCaseType] -> ShowS
show :: CCaseType -> String
$cshow :: CCaseType -> String
showsPrec :: Int -> CCaseType -> ShowS
$cshowsPrec :: Int -> CCaseType -> ShowS
Show)