summaryrefslogtreecommitdiff
path: root/src/GF/UseGrammar/Transfer.hs
blob: dfc08be1327b3ae1f7df5297ba8b12b7c9c7dd9a (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
38
39
40
41
42
43
----------------------------------------------------------------------
-- |
-- Module      : (Module)
-- Maintainer  : (Maintainer)
-- Stability   : (stable)
-- Portability : (portable)
--
-- > CVS $Date $ 
-- > CVS $Author $
-- > CVS $Revision $
--
-- (Description of the module)
-----------------------------------------------------------------------------

module Transfer where

import Grammar
import Values
import AbsCompute
import qualified GFC
import LookAbs
import MMacros
import TypeCheck

import Ident
import Operations

import Monad

-- linearize, parse, etc, by transfer. AR 9/10/2003

doTransfer :: GFC.CanonGrammar -> Ident -> Tree -> Err Tree
doTransfer gr tra t = do
  cat <- liftM snd $ val2cat $ valTree t
  f   <- lookupTransfer gr tra cat
  e   <- compute gr $ App f $ tree2exp t
  annotate gr e

useByTransfer :: (Tree -> Err a) -> GFC.CanonGrammar -> Ident -> (Tree -> Err a)
useByTransfer lin gr tra t = doTransfer gr tra t >>= lin

mkByTransfer :: (a -> Err [Tree]) -> GFC.CanonGrammar -> Ident -> (a -> Err [Tree])
mkByTransfer parse gr tra s = parse s >>= mapM (doTransfer gr tra)