clash-lib-1.7.0: Clash: a functional hardware description language - As a library
Copyright(C) 2021 QBayLogic B.V.
LicenseBSD2 (see the file LICENSE)
MaintainerQBayLogic B.V. <devops@qbaylogic.com>
Safe HaskellNone
LanguageHaskell2010

Clash.Core.HasType

Description

Utility class to extract type information from data which has a type.

Synopsis

Documentation

class HasType a where Source #

Methods

coreTypeOf :: a -> Type Source #

Instances

Instances details
HasType Literal Source # 
Instance details

Defined in Clash.Core.HasType

HasType TyCon Source # 
Instance details

Defined in Clash.Core.HasType

HasType Type Source # 
Instance details

Defined in Clash.Core.HasType

Methods

coreTypeOf :: Type -> Type Source #

HasType DataCon Source # 
Instance details

Defined in Clash.Core.HasType

HasType PrimInfo Source # 
Instance details

Defined in Clash.Core.HasType

HasType (Var a) Source # 
Instance details

Defined in Clash.Core.HasType

Methods

coreTypeOf :: Var a -> Type Source #

class InferType a where Source #

Instances

Instances details
InferType Type Source # 
Instance details

Defined in Clash.Core.HasType

InferType Term Source # 
Instance details

Defined in Clash.Core.HasType

InferType Value Source # 
Instance details

Defined in Clash.Core.Evaluator.Types

applyTypeToArgs Source #

Arguments

:: Term

The complete term, used for error messages.

-> TyConMap 
-> Type 
-> [Either Term Type] 
-> Type 

Get the result type of a polymorphic function given a list of arguments

piResultTy :: HasCallStack => TyConMap -> Type -> Type -> Type Source #

Like piResultTys, but only applies a single type. If multiple types are being applied use piResultTys, as it is more efficient to only substitute once with many types.

piResultTys :: HasCallStack => TyConMap -> Type -> [Type] -> Type Source #

(piResultTys f_ty [ty1, ..., tyn]) gives the type of (f ty1 .. tyn) where f :: f_ty

piResultTys is interesting because:

  1. f_ty may have more foralls than there are args
  2. Less obviously, it may have fewer foralls

Fore case 2. think of:

piResultTys (forall a . a) [forall b.b, Int]

This really can happen, such as situations involving undefineds type:

undefined :: forall a. a

undefined (forall b. b -> b) Int

This term should have the type (Int -> Int), but notice that there are more type args than foralls in undefineds type.

For efficiency reasons, when there are no foralls, we simply drop arrows from a function type/kind.