Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Definitions for representing Fortran values and types.
Synopsis
- data SemType
- type Kind = Int
- data CharacterLen
- type Dimensions = Dims NonEmpty (Maybe Int)
- data Dim a = Dim {}
- data Dims (t :: Type -> TYPE LiftedRep) a
- = DimsExplicitShape (t (Dim a))
- | DimsAssumedSize (Maybe (t (Dim a))) a
- | DimsAssumedShape (t a)
- dimensionsToTuples :: Dimensions -> Maybe [(Int, Int)]
- type Type = SemType
- data ExpVal
Types
Semantic type assigned to variables.
BaseType
stores the "type tag" given in syntax. SemType
s add metadata
(kind and length), and resolve some "simple" types to a core type with a
preset kind (e.g. `DOUBLE PRECISION` -> `REAL(8)`).
Fortran 90 (and beyond) features may not be well supported.
TInteger Kind | |
TReal Kind | |
TComplex Kind | |
TLogical Kind | |
TByte Kind | |
TCharacter CharacterLen Kind | |
TArray SemType Dimensions | A Fortran array type is represented by a type and a set of dimensions. |
TCustom String | Constructor to use for F77 structures, F90 DDTs |
Instances
data CharacterLen Source #
CharLenStar | specified with a * |
CharLenColon | specified with a : (Fortran2003) FIXME, possibly, with a more robust const-exp: |
CharLenExp | specified with a non-trivial expression |
CharLenInt Int | specified with a constant integer |
Instances
A single array dimension with bounds of type a
.
is a static, known-size dimension.Num
a =>Dim
a
is a dimension with unevaluated bounds expressions. Note that these bounds may be constant expressions, or refer to dummy variables, or be invalid.Dim
(Expression
()
)
is a dimension where some bounds are known, and others are not. This may be useful to record some information about dynamic explicit-shape arrays.Num
a =>Dim
(Maybe
a)
Instances
Foldable Dim | |
Defined in Language.Fortran.Common.Array fold :: Monoid m => Dim m -> m Source # foldMap :: Monoid m => (a -> m) -> Dim a -> m Source # foldMap' :: Monoid m => (a -> m) -> Dim a -> m Source # foldr :: (a -> b -> b) -> b -> Dim a -> b Source # foldr' :: (a -> b -> b) -> b -> Dim a -> b Source # foldl :: (b -> a -> b) -> b -> Dim a -> b Source # foldl' :: (b -> a -> b) -> b -> Dim a -> b Source # foldr1 :: (a -> a -> a) -> Dim a -> a Source # foldl1 :: (a -> a -> a) -> Dim a -> a Source # toList :: Dim a -> [a] Source # null :: Dim a -> Bool Source # length :: Dim a -> Int Source # elem :: Eq a => a -> Dim a -> Bool Source # maximum :: Ord a => Dim a -> a Source # minimum :: Ord a => Dim a -> a Source # | |
Traversable Dim | |
Functor Dim | |
Out a => Out (Dim a) | Fortran syntax uses |
FromJSON (Dim (Maybe Int)) Source # | |
Data a => Data (Dim a) | |
Defined in Language.Fortran.Common.Array gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Dim a -> c (Dim a) Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Dim a) Source # toConstr :: Dim a -> Constr Source # dataTypeOf :: Dim a -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Dim a)) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Dim a)) Source # gmapT :: (forall b. Data b => b -> b) -> Dim a -> Dim a Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Dim a -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Dim a -> r Source # gmapQ :: (forall d. Data d => d -> u) -> Dim a -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> Dim a -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Dim a -> m (Dim a) Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Dim a -> m (Dim a) Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Dim a -> m (Dim a) Source # | |
Generic (Dim a) | |
Show a => Show (Dim a) | |
Binary a => Binary (Dim a) | |
NFData a => NFData (Dim a) | |
Defined in Language.Fortran.Common.Array | |
Out (Dim a) => Pretty (Dim a) | |
Defined in Language.Fortran.Common.Array | |
Eq a => Eq (Dim a) | |
Ord a => Ord (Dim a) | |
Defined in Language.Fortran.Common.Array | |
type Rep (Dim a) | |
Defined in Language.Fortran.Common.Array type Rep (Dim a) = D1 ('MetaData "Dim" "Language.Fortran.Common.Array" "fortran-src-0.15.0-c374304f6a26b2e6e1e1e09dd9acee640e5193a35a08d212d6794a128ceb6d72" 'False) (C1 ('MetaCons "Dim" 'PrefixI 'True) (S1 ('MetaSel ('Just "dimLower") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a) :*: S1 ('MetaSel ('Just "dimUpper") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a))) |
data Dims (t :: Type -> TYPE LiftedRep) a Source #
Fortran array dimensions, defined by a list of Dim
s storing lower and
upper bounds.
You select the list type t
(which should be Functor
, Foldable
and
Traversable
) and the bound type a
(e.g. Int
).
Using a non-empty list type such as NonEmpty
will
disallow representing zero-dimension arrays, providing extra soundness.
Note the following excerpt from the F2018 standard (8.5.8.2 Explicit-shape array):
If the upper bound is less than the lower bound, the range is empty, the extent in that dimension is zero, and the array is of zero size.
Note that the Foldable
instance does not provide "dimension-like" access to
this type. That is,
will _not_ tell you how many
dimensions length
(a :: Dims
t a)a
represents. Use dimsLength
for that.
DimsExplicitShape | Explicit-shape array. All dimensions are known. |
| |
DimsAssumedSize | Assumed-size array. The final dimension has no upper bound (it is obtained from its effective argument). Earlier dimensions may be defined like explicit-shape arrays. |
DimsAssumedShape | Assumed-shape array. Shape is taken from effective argument. We store the lower bound for each dimension, and thus also the rank (via list length). |
|
Instances
FromJSON Dimensions Source # | |
Defined in Language.Fortran.Vars.Orphans parseJSON :: Value -> Parser Dimensions Source # parseJSONList :: Value -> Parser [Dimensions] Source # | |
Foldable t => Foldable (Dims t) | |
Defined in Language.Fortran.Common.Array fold :: Monoid m => Dims t m -> m Source # foldMap :: Monoid m => (a -> m) -> Dims t a -> m Source # foldMap' :: Monoid m => (a -> m) -> Dims t a -> m Source # foldr :: (a -> b -> b) -> b -> Dims t a -> b Source # foldr' :: (a -> b -> b) -> b -> Dims t a -> b Source # foldl :: (b -> a -> b) -> b -> Dims t a -> b Source # foldl' :: (b -> a -> b) -> b -> Dims t a -> b Source # foldr1 :: (a -> a -> a) -> Dims t a -> a Source # foldl1 :: (a -> a -> a) -> Dims t a -> a Source # toList :: Dims t a -> [a] Source # null :: Dims t a -> Bool Source # length :: Dims t a -> Int Source # elem :: Eq a => a -> Dims t a -> Bool Source # maximum :: Ord a => Dims t a -> a Source # minimum :: Ord a => Dims t a -> a Source # | |
Traversable t => Traversable (Dims t) | |
Defined in Language.Fortran.Common.Array | |
Functor t => Functor (Dims t) | |
(Foldable t, Functor t, Out (Dim a), Out a) => Out (Dims t a) | |
(Data a, Data (t a), Data (t (Dim a)), Typeable t) => Data (Dims t a) | |
Defined in Language.Fortran.Common.Array gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Dims t a -> c (Dims t a) Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Dims t a) Source # toConstr :: Dims t a -> Constr Source # dataTypeOf :: Dims t a -> DataType Source # dataCast1 :: Typeable t0 => (forall d. Data d => c (t0 d)) -> Maybe (c (Dims t a)) Source # dataCast2 :: Typeable t0 => (forall d e. (Data d, Data e) => c (t0 d e)) -> Maybe (c (Dims t a)) Source # gmapT :: (forall b. Data b => b -> b) -> Dims t a -> Dims t a Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Dims t a -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Dims t a -> r Source # gmapQ :: (forall d. Data d => d -> u) -> Dims t a -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> Dims t a -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Dims t a -> m (Dims t a) Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Dims t a -> m (Dims t a) Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Dims t a -> m (Dims t a) Source # | |
Generic (Dims t a) | |
(Show a, Show (t a), Show (t (Dim a))) => Show (Dims t a) | |
(Binary a, Binary (t a), Binary (t (Dim a))) => Binary (Dims t a) | |
(NFData a, NFData (t a), NFData (t (Dim a))) => NFData (Dims t a) | |
Defined in Language.Fortran.Common.Array | |
Out (Dims t a) => Pretty (Dims t a) | |
Defined in Language.Fortran.Common.Array | |
(Eq a, Eq (t a), Eq (t (Dim a))) => Eq (Dims t a) | |
(Ord a, Ord (t a), Ord (t (Dim a))) => Ord (Dims t a) | This instance is purely for convenience. No definition of ordering is provided, and the implementation may change at any time. |
Defined in Language.Fortran.Common.Array | |
type Rep (Dims t a) | |
Defined in Language.Fortran.Common.Array type Rep (Dims t a) = D1 ('MetaData "Dims" "Language.Fortran.Common.Array" "fortran-src-0.15.0-c374304f6a26b2e6e1e1e09dd9acee640e5193a35a08d212d6794a128ceb6d72" 'False) (C1 ('MetaCons "DimsExplicitShape" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (t (Dim a)))) :+: (C1 ('MetaCons "DimsAssumedSize" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe (t (Dim a)))) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)) :+: C1 ('MetaCons "DimsAssumedShape" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (t a))))) |
Compatibility
dimensionsToTuples :: Dimensions -> Maybe [(Int, Int)] Source #
Convert Dimensions
data type to its previous type synonym
(Maybe [(Int, Int)])
.
Drops all information for array dimensions that aren't fully static/known.
Values
The evaluated value of a FORTRAN expression.