mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-15 15:59:32 -06:00
+ References to modules under src/compiler have been eliminated from the PGF library (under src/runtime/haskell). Only two functions had to be moved (from GF.Data.Utilities to PGF.Utilities) to make this possible, other apparent dependencies turned out to be vacuous. + In gf.cabal, the GF executable no longer directly depends on the PGF library source directory, but only on the exposed library modules. This means that there is less duplication in gf.cabal and that the 30 modules in the PGF library will no longer be compiled twice while building GF. To make this possible, additional PGF library modules have been exposed, even though they should probably be considered for internal use only. They could be collected in a PGF.Internal module, or marked as "unstable", to make this explicit. + Also, by using the -fwarn-unused-imports flag, ~220 redundant imports were found and removed, reducing the total number of imports by ~15%.
56 lines
1.8 KiB
Haskell
56 lines
1.8 KiB
Haskell
module GF.Compile.Compute.Value where
|
|
import GF.Grammar.Grammar(Label,Type,MetaId,Patt,QIdent)
|
|
import PGF.Data(BindType)
|
|
import GF.Infra.Ident(Ident)
|
|
import Text.Show.Functions()
|
|
import Data.Ix(Ix)
|
|
|
|
-- | Self-contained (not quite) representation of values
|
|
data Value
|
|
= VApp Predefined [Value] -- from Q, always Predef.x, has a built-in value
|
|
| VCApp QIdent [Value] -- from QC, constructors
|
|
| VGen Int [Value] -- for lambda bound variables, possibly applied
|
|
| VMeta MetaId Env [Value]
|
|
-- | VClosure Env Term -- used in Typecheck.ConcreteNew
|
|
| VAbs BindType Ident Binding -- used in Compute.ConcreteNew
|
|
| VProd BindType Value Ident Binding -- used in Compute.ConcreteNew
|
|
| VInt Int
|
|
| VFloat Double
|
|
| VString String
|
|
| VSort Ident
|
|
| VImplArg Value
|
|
| VTblType Value Value
|
|
| VRecType [(Label,Value)]
|
|
| VRec [(Label,Value)]
|
|
| VV Type [Value] [Value] -- preserve type for conversion back to Term
|
|
| VT Wild Value [(Patt,Bind Env)]
|
|
| VC Value Value
|
|
| VS Value Value
|
|
| VP Value Label
|
|
| VPatt Patt
|
|
| VPattType Value
|
|
| VFV [Value]
|
|
| VAlts Value [(Value, Value)]
|
|
| VStrs [Value]
|
|
-- | VGlue Value Value -- hmm
|
|
| VExtR Value Value -- hmm
|
|
| VError String
|
|
deriving (Eq,Show)
|
|
|
|
type Wild = Bool
|
|
type Binding = Bind Value
|
|
data Bind a = Bind (a->Value) deriving Show
|
|
|
|
instance Eq (Bind a) where x==y = False
|
|
|
|
type Env = [(Ident,Value)]
|
|
|
|
-- | Predefined functions
|
|
data Predefined = Drop | Take | Tk | Dp | EqStr | Occur | Occurs | ToUpper
|
|
| ToLower | IsUpper | Length | Plus | EqInt | LessInt
|
|
{- | Show | Read | ToStr | MapStr | EqVal -}
|
|
| Error
|
|
-- Canonical values below:
|
|
| PBool | PFalse | PTrue | Int | Ints | NonExist | BIND
|
|
deriving (Show,Eq,Ord,Ix,Bounded,Enum)
|