hakaru-0.7.0: A probabilistic programming language
CopyrightCopyright (c) 2017 the Hakaru team
LicenseBSD3
Stabilityexperimental
PortabilityGHC-only
Safe HaskellNone
LanguageHaskell2010

Language.Hakaru.Syntax.TypeCheck.TypeCheckMonad

Description

Bidirectional type checking for our AST.

Synopsis

Documentation

type Input = Maybe (Vector Text) Source #

  • Definition of the typechecking monad and related types/functions/instances.

getInput :: TypeCheckMonad Input Source #

Return the mode in which we're checking/inferring types.

getMode :: TypeCheckMonad TypeCheckMode Source #

Return the mode in which we're checking/inferring types.

pushCtx :: Variable (a :: Hakaru) -> TypeCheckMonad b -> TypeCheckMonad b Source #

Extend the typing context, but only locally.

try :: TypeCheckMonad a -> TypeCheckMonad (Maybe a) Source #

a la optional :: Alternative f => f a -> f (Maybe a) but without needing the empty of the Alternative class.

tryWith :: TypeCheckMode -> TypeCheckMonad a -> TypeCheckMonad (Maybe a) Source #

Tries to typecheck in a given mode

makeErrMsg :: Text -> Maybe SourceSpan -> Text -> TypeCheckMonad TypeCheckError Source #

  • Helpers for constructing error messages

typeMismatch :: Maybe SourceSpan -> Either Text (Sing (a :: Hakaru)) -> Either Text (Sing (b :: Hakaru)) -> TypeCheckMonad r Source #

Fail with a type-mismatch error.

data TypedAST (abt :: [Hakaru] -> Hakaru -> *) Source #

  • Terms whose type is existentially quantified packed with a singleton for the type.

The e' ∈ τ portion of the inference judgement.

Constructors

forall b. TypedAST !(Sing b) !(abt '[] b) 

Instances

Instances details
Show2 abt => Show (TypedAST abt) Source # 
Instance details

Defined in Language.Hakaru.Syntax.TypeCheck.TypeCheckMonad

Methods

showsPrec :: Int -> TypedAST abt -> ShowS #

show :: TypedAST abt -> String #

showList :: [TypedAST abt] -> ShowS #

onTypedAST :: (forall b. abt '[] b -> abt '[] b) -> TypedAST abt -> TypedAST abt Source #

onTypedASTM :: Functor m => (forall b. abt '[] b -> m (abt '[] b)) -> TypedAST abt -> m (TypedAST abt) Source #

elimTypedAST :: (forall b. Sing b -> abt '[] b -> x) -> TypedAST abt -> x Source #

data TypedASTs (abt :: [Hakaru] -> Hakaru -> *) Source #

Constructors

forall b. TypedASTs !(Sing b) [abt '[] b] 

data TypedReducer (abt :: [Hakaru] -> Hakaru -> *) (xs :: [Hakaru]) Source #

Constructors

forall b. TypedReducer !(Sing b) (List1 Variable xs) (Reducer abt xs b) 

data SomePattern (a :: Hakaru) Source #

Constructors

forall vars. SP !(Pattern vars a) !(List1 Variable vars) 

data SomePatternCode xss t Source #

Constructors

forall vars. SPC !(PDatumCode xss vars (HData' t)) !(List1 Variable vars) 

data SomePatternStruct xs t Source #

Constructors

forall vars. SPS !(PDatumStruct xs vars (HData' t)) !(List1 Variable vars) 

data SomePatternFun x t Source #

Constructors

forall vars. SPF !(PDatumFun x vars (HData' t)) !(List1 Variable vars) 

data SomeBranch a abt Source #

Constructors

forall b. SomeBranch !(Sing b) [Branch a abt b] 

makeVar :: forall (a :: Hakaru). Variable 'U -> Sing a -> Variable a Source #

  • Misc.

jmEq1_ :: Sing (a :: Hakaru) -> Sing (b :: Hakaru) -> TypeCheckMonad (TypeEq a b) Source #

lc :: (LC_ abt a -> LC_ abt b) -> abt '[] a -> abt '[] b Source #

coerceTo_nonLC :: ABT Term abt => Coercion a b -> abt xs a -> abt xs b Source #

coerceFrom_nonLC :: ABT Term abt => Coercion a b -> abt xs b -> abt xs a Source #

Orphan instances

ABT Term abt => Coerce (Branch a abt) Source # 
Instance details

Methods

coerceTo :: forall (a0 :: Hakaru) (b :: Hakaru). Coercion a0 b -> Branch a abt a0 -> Branch a abt b Source #

coerceFrom :: forall (a0 :: Hakaru) (b :: Hakaru). Coercion a0 b -> Branch a abt b -> Branch a abt a0 Source #