~ubuntu-branches/ubuntu/raring/agda/raring-proposed

« back to all changes in this revision

Viewing changes to src/full/Agda/TypeChecking/Empty.hs

  • Committer: Bazaar Package Importer
  • Author(s): Iain Lane
  • Date: 2009-07-20 19:49:41 UTC
  • Revision ID: james.westby@ubuntu.com-20090720194941-hcjy91vrn16csh7d
Tags: upstream-2.2.4+dfsg
ImportĀ upstreamĀ versionĀ 2.2.4+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
module Agda.TypeChecking.Empty where
 
3
 
 
4
import Control.Applicative
 
5
 
 
6
import Agda.Syntax.Common
 
7
import Agda.Syntax.Internal
 
8
 
 
9
import Agda.TypeChecking.Monad
 
10
import Agda.TypeChecking.Coverage
 
11
import Agda.TypeChecking.Constraints
 
12
import Agda.TypeChecking.Reduce
 
13
 
 
14
import Agda.Utils.Permutation
 
15
import Agda.Utils.Size
 
16
 
 
17
-- | Make sure that a type is empty.
 
18
isEmptyType :: MonadTCM tcm => Type -> tcm ()
 
19
isEmptyType t = noConstraints $ isEmptyTypeC t
 
20
 
 
21
isEmptyTypeC :: MonadTCM tcm => Type -> tcm Constraints
 
22
isEmptyTypeC t = do
 
23
  tb <- reduceB t
 
24
  let t = ignoreBlocking tb
 
25
  case unEl <$> tb of
 
26
    NotBlocked MetaV{} -> buildConstraint (IsEmpty t)
 
27
    Blocked{}          -> buildConstraint (IsEmpty t)
 
28
    _                  -> do
 
29
      tel0 <- getContextTelescope
 
30
      let tel = telFromList $ telToList tel0 ++ [Arg NotHidden ("_", t)]
 
31
          ps  = [ Arg h $ VarP x | Arg h (x, _) <- telToList tel ]
 
32
 
 
33
      r <- split tel (idP $ size tel) ps 0
 
34
 
 
35
      case r of
 
36
        Left err  -> typeError $ ShouldBeEmpty t []
 
37
        Right []  -> return []
 
38
        Right cs  -> typeError $ ShouldBeEmpty t $ map (unArg . last . scPats) cs
 
39