mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-23 03:32:51 -06:00
API for constructing types
This commit is contained in:
@@ -16,7 +16,9 @@ module PGF ( PGF2.PGF, readPGF
|
|||||||
, PGF2.mkFloat, PGF2.unFloat
|
, PGF2.mkFloat, PGF2.unFloat
|
||||||
, PGF2.mkMeta, PGF2.unMeta
|
, PGF2.mkMeta, PGF2.unMeta
|
||||||
|
|
||||||
, PGF2.Type, PGF2.Hypo
|
, PGF2.Type(..), PGF2.Hypo
|
||||||
|
, PGF2.mkType, PGF2.unType
|
||||||
|
, PGF2.mkHypo, PGF2.mkDepHypo, PGF2.mkImplHypo
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import qualified PGF2 as PGF2
|
import qualified PGF2 as PGF2
|
||||||
|
|||||||
@@ -35,6 +35,8 @@ module PGF2 (-- * PGF
|
|||||||
-- ** Types
|
-- ** Types
|
||||||
Type(..), Hypo, BindType(..),
|
Type(..), Hypo, BindType(..),
|
||||||
readType,
|
readType,
|
||||||
|
mkType, unType,
|
||||||
|
mkHypo, mkDepHypo, mkImplHypo,
|
||||||
-- * Concrete syntax
|
-- * Concrete syntax
|
||||||
ConcName
|
ConcName
|
||||||
) where
|
) where
|
||||||
|
|||||||
@@ -10,6 +10,10 @@ module PGF2.Expr(Var, Cat, Fun,
|
|||||||
mkDouble, unDouble,
|
mkDouble, unDouble,
|
||||||
mkFloat, unFloat,
|
mkFloat, unFloat,
|
||||||
mkMeta, unMeta,
|
mkMeta, unMeta,
|
||||||
|
|
||||||
|
mkType, unType,
|
||||||
|
mkHypo, mkDepHypo, mkImplHypo
|
||||||
|
|
||||||
) where
|
) where
|
||||||
|
|
||||||
type Var = String -- ^ Name of syntactic category
|
type Var = String -- ^ Name of syntactic category
|
||||||
@@ -147,3 +151,26 @@ unMeta (EMeta i) = Just i
|
|||||||
unMeta (ETyped e ty) = unMeta e
|
unMeta (ETyped e ty) = unMeta e
|
||||||
unMeta (EImplArg e) = unMeta e
|
unMeta (EImplArg e) = unMeta e
|
||||||
unMeta _ = Nothing
|
unMeta _ = Nothing
|
||||||
|
|
||||||
|
|
||||||
|
-- | creates a type from list of hypothesises, category and
|
||||||
|
-- list of arguments for the category. The operation
|
||||||
|
-- @mkType [h_1,...,h_n] C [e_1,...,e_m]@ will create
|
||||||
|
-- @h_1 -> ... -> h_n -> C e_1 ... e_m@
|
||||||
|
mkType :: [Hypo] -> Cat -> [Expr] -> Type
|
||||||
|
mkType hyps cat args = DTyp hyps cat args
|
||||||
|
|
||||||
|
-- | creates hypothesis for non-dependent type i.e. A
|
||||||
|
mkHypo :: Type -> Hypo
|
||||||
|
mkHypo ty = (Explicit,"_",ty)
|
||||||
|
|
||||||
|
-- | creates hypothesis for dependent type i.e. (x : A)
|
||||||
|
mkDepHypo :: Var -> Type -> Hypo
|
||||||
|
mkDepHypo x ty = (Explicit,x,ty)
|
||||||
|
|
||||||
|
-- | creates hypothesis for dependent type with implicit argument i.e. ({x} : A)
|
||||||
|
mkImplHypo :: Var -> Type -> Hypo
|
||||||
|
mkImplHypo x ty = (Implicit,x,ty)
|
||||||
|
|
||||||
|
unType :: Type -> ([Hypo], Cat, [Expr])
|
||||||
|
unType (DTyp hyps cat es) = (hyps, cat, es)
|
||||||
|
|||||||
Reference in New Issue
Block a user