Karya, built on 2018-05-31T02:46:59 (patch 0a1a35479c514820d77330ae8a978975ba22a47a)

Safe HaskellNone

Derive.ValType

Description

Type descriptions of the Val.

This is in its own module so Derive.Deriver.Monad can import it without importing Derive.Typecheck.

Synopsis

Documentation

data Type Source #

Constructors

TNum NumType NumValue 
TAttributes 
TControlRef 
TPControlRef 
TPitch 
TNotePitch 
TStr (Maybe [Text])

Text string, with enum values if it's an enum.

TControl 
TPControl 
TNotGiven 
TSeparator 
TMaybe Type 
TEither Type Type 
TVal

This is the "any" type.

TPair Type Type

Two types in sequence. This has no corresponding Typecheck instance since it doesn't correspond to a single Val, but is used by Derive.Sig for documentation.

TQuoted

A VQuoted. This has no Typecheck instance so it should never show up as a call argument.

TControlFunction 
TList !Type 
TOther !Text

Typecheck instances that don't correspond directly to a Val type get this, as a plain description.

Instances
Eq Type # 
Instance details

Defined in Derive.ValType

Methods

(==) :: Type -> Type -> Bool #

(/=) :: Type -> Type -> Bool #

Ord Type # 
Instance details

Defined in Derive.ValType

Methods

compare :: Type -> Type -> Ordering #

(<) :: Type -> Type -> Bool #

(<=) :: Type -> Type -> Bool #

(>) :: Type -> Type -> Bool #

(>=) :: Type -> Type -> Bool #

max :: Type -> Type -> Type #

min :: Type -> Type -> Type #

Show Type # 
Instance details

Defined in Derive.ValType

Methods

showsPrec :: Int -> Type -> ShowS #

show :: Type -> String #

showList :: [Type] -> ShowS #

Pretty Type # 
Instance details

Defined in Derive.ValType

data NumType Source #

These are kind of muddled. This is because they were originally just documentation, so the more specific the better, but are also used for typechecking in put_val, so the subtype relations need to be respected. But since some are just documentation (e.g. TDefaultReal), they should never show up on the LHS of a put_val typecheck.

Instances
Eq NumType # 
Instance details

Defined in Derive.ValType

Methods

(==) :: NumType -> NumType -> Bool #

(/=) :: NumType -> NumType -> Bool #

Ord NumType # 
Instance details

Defined in Derive.ValType

Show NumType # 
Instance details

Defined in Derive.ValType

Pretty NumType # 
Instance details

Defined in Derive.ValType

data NumValue Source #

Numeric subtypes.

Constructors

TAny 
TNonNegative
=0
TPositive
0
TNormalized

0 <= a <= 1

Instances
Eq NumValue # 
Instance details

Defined in Derive.ValType

Ord NumValue # 
Instance details

Defined in Derive.ValType

Show NumValue # 
Instance details

Defined in Derive.ValType

Pretty NumValue # 
Instance details

Defined in Derive.ValType

types_match :: Type -> Type -> Bool Source #

This typechecking already exists in the Typecheck instances, but all it can do is go from a Val to a Typecheck a => Maybe a. So I can't reuse it to check a type against a type, so it has to be duplicated, similar to how type_of can't reuse to_type.

The result is I have redundant functions like subtypes_of and type_of and to_num_type, and a mistake or inconsistency with to_type or to_val will cause typechecking to fail in some subtle case. Fortunately there are relatively few types and hopefully won't be many more, and it only affects put_val. It could all do with a cleanup. I'm sure there's a right way to do this sort of thing.

val_types_match :: Val -> Val -> Maybe Type Source #

Nothing if the type of the rhs matches the lhs, otherwise the expected type.

infer_type_of Source #

Arguments

:: Bool

If True, infer the most specific type possible. Otherwise, infer a general type. This is because if put_val gets a 1 it doesn't mean it's intended to be a TPositive.

-> Val 
-> Type