module DDC.Core.Salt.Name.PrimControl ( PrimControl (..) , readPrimControl) where import DDC.Data.Pretty import Control.DeepSeq -- | Primitive non-returning control flow. data PrimControl -- | Ungraceful failure -- just abort the program. -- This is called on internal errors in the runtime system. -- There is no further debugging info provided, so you'll need to -- look at the stack trace to debug it. = PrimControlFail -- | Return from the enclosing function with the given value. | PrimControlReturn deriving (Eq, Ord, Show) instance NFData PrimControl where rnf !_ = () instance Pretty PrimControl where ppr pc = case pc of PrimControlFail -> text "fail#" PrimControlReturn -> text "return#" readPrimControl :: String -> Maybe PrimControl readPrimControl str = case str of "fail#" -> Just $ PrimControlFail "return#" -> Just $ PrimControlReturn _ -> Nothing