summaryrefslogtreecommitdiff
path: root/src/GF/Grammar/Lockfield.hs
blob: 3cdfdaa54eda077b9bd3f0b1a55d3c9c22090cb9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
----------------------------------------------------------------------
-- |
-- Module      : (Module)
-- Maintainer  : (Maintainer)
-- Stability   : (stable)
-- Portability : (portable)
--
-- > CVS $Date $ 
-- > CVS $Author $
-- > CVS $Revision $
--
-- Creating and using lock fields in reused resource grammars.
-----------------------------------------------------------------------------

module Lockfield (lockRecType, unlockRecord, lockLabel) where

import Grammar
import Ident
import Macros
import PrGrammar

import Operations

-- AR 8/2/2005 detached from compile/MkResource

lockRecType :: Ident -> Type -> Err Type
lockRecType c t = plusRecType t $ RecType [(lockLabel c,  RecType [])]

unlockRecord :: Ident -> Term -> Err Term
unlockRecord c ft = do
  let (xs,t) = termFormCnc ft
  t' <- plusRecord t $ R [(lockLabel c,  (Just (RecType []),R []))]
  return $ mkAbs xs t'

lockLabel :: Ident -> Label
lockLabel c = LIdent $ "lock_" ++ prt c ----