3
module Agda.Syntax.Strict where
7
import Agda.Syntax.Common
8
import Agda.Syntax.Internal
9
import Agda.Syntax.Parser.Tokens
10
import qualified Agda.Syntax.Concrete as C
11
import qualified Agda.Syntax.Concrete.Definitions as C
13
#include "../undefined.h"
14
import Agda.Utils.Impossible
19
instance Strict Term where
27
Fun a b -> force (a,b)
29
MetaV _ ts -> force ts
31
instance Strict Type where
32
force (El s t) = force (s,t)
34
instance Strict Sort where
36
Type n -> fromIntegral n
38
Lub s1 s2 -> force (s1,s2)
42
instance Strict ClauseBody where
43
force (Body t) = force t
44
force (Bind b) = force b
45
force (NoBind b) = force b
48
instance Strict C.Expr where
49
force e = everything (+) (const 1) e
51
instance Strict C.Declaration where
52
force e = everything (+) (const 1) e
54
instance Strict C.Pragma where
55
force e = everything (+) (const 1) e
57
instance Strict C.NiceDeclaration where
58
force d = everything (+) (const 1) d
60
instance (Strict a, Strict b) => Strict (a,b) where
61
force (x,y) = force x + force y
63
instance Strict a => Strict (Arg a) where
66
instance Strict a => Strict [a] where
67
force = sum . map force
69
instance Strict a => Strict (Abs a) where
70
force = force . absBody
72
instance Strict Token where
73
-- TODO: This is just a dummy instance. Why can't we just use the
74
-- NFData derivation provided by Drift?
79
($!!) :: Strict a => (a -> b) -> a -> b
80
f $!! x = force x `seq` f x
82
strict :: Strict a => a -> a