Skip to content

Commit

Permalink
Move ResumeKind to separate module to fix dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
b-studios committed Aug 2, 2018
1 parent 3441170 commit 85e75f8
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 28 deletions.
1 change: 1 addition & 0 deletions Jakefile.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ var hsModules = [
"Common.Message",
"Common.Unique",
"Common.Error",
"Common.ResumeKind",

"Syntax.Lexeme",
alexModule("Syntax.Lexer"),
Expand Down
34 changes: 34 additions & 0 deletions src/Common/ResumeKind.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
-----------------------------------------------------------------------------
-- Copyright 2018 Microsoft Corporation.
--
-- This is free software; you can redistribute it and/or modify it under the
-- terms of the Apache License, Version 2.0. A copy of the License can be
-- found in the file "license.txt" at the root of this distribution.
-----------------------------------------------------------------------------
{-
Kinds describing how an operation is using the resumption.
-}
-----------------------------------------------------------------------------
module Common.ResumeKind ( ResumeKind(..) ) where

data ResumeKind
= ResumeNever
| ResumeTail
| ResumeScopedOnce
| ResumeScoped
| ResumeOnce
| ResumeNormal
| ResumeOnceRaw
| ResumeNormalRaw
deriving (Eq,Ord,Enum)

instance Show ResumeKind where
show rk = case rk of
ResumeNever -> "never"
ResumeTail -> "tail"
ResumeScopedOnce -> "scoped once"
ResumeScoped -> "scoped"
ResumeOnce -> "once"
ResumeNormal -> "normal"
ResumeOnceRaw -> "once (no finalization)"
ResumeNormalRaw -> "normal (no finalization)"
25 changes: 2 additions & 23 deletions src/Core/AnalysisResume.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
-}
-----------------------------------------------------------------------------

module Core.AnalysisResume( ResumeKind(..), analyzeResume ) where
module Core.AnalysisResume( analyzeResume ) where


import Lib.Trace
Expand All @@ -22,35 +22,14 @@ import Common.Range
import Common.Failure
import Common.Unique()
import Common.NamePrim( namePatternMatchError, nameSystemCore )
import Common.ResumeKind( ResumeKind(..) )
import Kind.Kind( kindStar )
import Type.Type
import Type.Pretty (defaultEnv)
import Core.Core
import Core.CoreVar
import Core.Pretty

data ResumeKind
= ResumeNever
| ResumeTail
| ResumeScopedOnce
| ResumeScoped
| ResumeOnce
| ResumeNormal
| ResumeOnceRaw
| ResumeNormalRaw
deriving (Eq,Ord,Enum)

instance Show ResumeKind where
show rk = case rk of
ResumeNever -> "never"
ResumeTail -> "tail"
ResumeScopedOnce -> "scoped once"
ResumeScoped -> "scoped"
ResumeOnce -> "once"
ResumeNormal -> "normal"
ResumeOnceRaw -> "once (no finalization)"
ResumeNormalRaw -> "normal (no finalization)"

analyzeResume :: Name -> Name -> Bool -> Expr -> ResumeKind
analyzeResume defName opName raw expr
= case expr of
Expand Down
3 changes: 1 addition & 2 deletions src/Syntax/Parse.hs
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,14 @@ import Platform.Config
import Platform.Runtime( unsafePerformIO, exCatch )
import Common.Error
import Common.Syntax
import Common.ResumeKind

import Syntax.Syntax
import Syntax.Lexeme
import Syntax.Lexer ( lexing )
import Syntax.Layout ( layout )
import Syntax.Promote ( promote, promoteType, quantify, promoteFree )

import Core.AnalysisResume( ResumeKind(..) )

-----------------------------------------------------------
-- Parser on token stream
-----------------------------------------------------------
Expand Down
3 changes: 2 additions & 1 deletion src/Syntax/Syntax.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ import Common.NamePrim( nameTrue, nameSystemCore )
import Common.Name
import Common.Range
import Common.Failure( failure )
import Common.ResumeKind
import Common.Syntax
import qualified Common.NameSet as S

import Core.AnalysisResume( ResumeKind(..) )


-- | A program
data Program t k
Expand Down
4 changes: 2 additions & 2 deletions src/Type/Infer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ import Type.InferMonad

import qualified Core.CoreVar as CoreVar
import Core.AnalysisMatch( analyzeBranches )
import Core.AnalysisResume( analyzeResume, ResumeKind(..) )

import Common.ResumeKind
import Core.AnalysisResume
import Core.Divergent( analyzeDivergence )
import Core.BindingGroups( regroup )
import Core.Simplify( uniqueSimplify )
Expand Down

0 comments on commit 85e75f8

Please sign in to comment.