numeric-prelude-0.4.4: An experimental alternative hierarchy of numeric type classes
Safe HaskellNone
LanguageHaskell98

Algebra.OccasionallyScalar

Description

There are several types of numbers where a subset of numbers can be considered as set of scalars.

  • A '(Complex.T Double)' value can be converted to Double if the imaginary part is zero.
  • A value with physical units can be converted to a scalar if there is no unit.

Of course this can be cascaded, e.g. a complex number with physical units can be converted to a scalar if there is both no imaginary part and no unit.

This is somewhat similar to the multi-type classes NormedMax.C and friends.

I hesitate to define an instance for lists to avoid the mess known of MatLab. But if you have an application where you think you need this instance definitely I'll think about that, again.

Documentation

class C a v where Source #

Methods

toScalar :: v -> a Source #

toMaybeScalar :: v -> Maybe a Source #

fromScalar :: a -> v Source #

Instances

Instances details
C Double Double Source # 
Instance details

Defined in Algebra.OccasionallyScalar

C Float Float Source # 
Instance details

Defined in Algebra.OccasionallyScalar

(Show v, C v, C v, C a v) => C a (T v) Source # 
Instance details

Defined in Number.Complex

Methods

toScalar :: T v -> a Source #

toMaybeScalar :: T v -> Maybe a Source #

fromScalar :: a -> T v Source #

(C a v, Show v) => C a (T a v) Source # 
Instance details

Defined in Number.OccasionallyScalarExpression

Methods

toScalar :: T a v -> a Source #

toMaybeScalar :: T a v -> Maybe a Source #

fromScalar :: a -> T a v Source #

(IsScalar u, C a b) => C a (T u b) Source # 
Instance details

Defined in Number.DimensionTerm

Methods

toScalar :: T u b -> a Source #

toMaybeScalar :: T u b -> Maybe a Source #

fromScalar :: a -> T u b Source #

C a v => C a (T i v) Source # 
Instance details

Defined in Number.Physical

Methods

toScalar :: T i v -> a Source #

toMaybeScalar :: T i v -> Maybe a Source #

fromScalar :: a -> T i v Source #

(C a, Ord a, C a v, Show v, C a v) => C a (T a v) Source # 
Instance details

Defined in Number.SI

Methods

toScalar :: T a v -> a Source #

toMaybeScalar :: T a v -> Maybe a Source #

fromScalar :: a -> T a v Source #

C a v => C (T a) (T v) Source # 
Instance details

Defined in MathObj.Wrapper.NumericPrelude

Methods

toScalar :: T v -> T a Source #

toMaybeScalar :: T v -> Maybe (T a) Source #

fromScalar :: T a -> T v Source #

toScalarDefault :: C a v => v -> a Source #

toScalarShow :: (C a v, Show v) => v -> a Source #