telescope-0.2.0: Astronomical Observations (FITS, ASDF, WCS, etc)
Safe HaskellNone
LanguageGHC2021

Telescope.Asdf.Class

Synopsis

Documentation

class ToAsdf a where Source #

Convert a type to an Asdf Value or Node. The generic instance will encode to an Object with field names matching record selectors

data Example = Example
  { name :: Text
  , age :: Int
  , tags :: [Text]
  }
  deriving (Generic, ToAsdf)

instance ToAsdf Example where
  schema _ = "tag:example.org/schemas/example-1.0.0"

Minimal complete definition

Nothing

Methods

toValue :: a -> Value Source #

Specify how an object encodes to a Value

instance User ToAsdf where
  toValue user =
    Object
      [ ("name", toNode user.name)
      , ("age", toNode user.age)
      ]

default toValue :: (Generic a, GToObject (Rep a)) => a -> Value Source #

schema :: a -> SchemaTag Source #

Specify the schema for a type

instance ToAsdf Unit where
  schema _ = "!unit/unit-1.0.0"

default schema :: a -> SchemaTag Source #

anchor :: a -> Maybe Anchor Source #

Specify that this node be saved as an anchor

instance ToAsdf Config where
  anchor _ = Just "globalConfig"

default anchor :: a -> Maybe Anchor Source #

toNode :: a -> Node Source #

Manually control all aspects of how this is converted to a Node

default toNode :: a -> Node Source #

Instances

Instances details
ToAsdf ByteOrder Source # 
Instance details

Defined in Telescope.Asdf.Class

ToAsdf Int16 Source # 
Instance details

Defined in Telescope.Asdf.Class

ToAsdf Int32 Source # 
Instance details

Defined in Telescope.Asdf.Class

ToAsdf Int64 Source # 
Instance details

Defined in Telescope.Asdf.Class

ToAsdf Int8 Source # 
Instance details

Defined in Telescope.Asdf.Class

ToAsdf Asdf Source # 
Instance details

Defined in Telescope.Asdf.Core

ToAsdf ExtensionMetadata Source # 
Instance details

Defined in Telescope.Asdf.Core

ToAsdf History Source # 
Instance details

Defined in Telescope.Asdf.Core

ToAsdf Quantity Source # 
Instance details

Defined in Telescope.Asdf.Core

ToAsdf Software Source # 
Instance details

Defined in Telescope.Asdf.Core

ToAsdf Unit Source # 
Instance details

Defined in Telescope.Asdf.Core

ToAsdf BlockSource Source # 
Instance details

Defined in Telescope.Asdf.Class

ToAsdf Affine Source # 
Instance details

Defined in Telescope.Asdf.GWCS

ToAsdf AxisName Source # 
Instance details

Defined in Telescope.Asdf.GWCS

ToAsdf AxisType Source # 
Instance details

Defined in Telescope.Asdf.GWCS

ToAsdf CelestialFrame Source # 
Instance details

Defined in Telescope.Asdf.GWCS

ToAsdf CoordinateFrame Source # 
Instance details

Defined in Telescope.Asdf.GWCS

ToAsdf Direction Source # 
Instance details

Defined in Telescope.Asdf.GWCS

ToAsdf ICRSFrame Source # 
Instance details

Defined in Telescope.Asdf.GWCS

ToAsdf Identity Source # 
Instance details

Defined in Telescope.Asdf.GWCS

ToAsdf Lat Source # 
Instance details

Defined in Telescope.Asdf.GWCS

ToAsdf Lon Source # 
Instance details

Defined in Telescope.Asdf.GWCS

ToAsdf LonPole Source # 
Instance details

Defined in Telescope.Asdf.GWCS

ToAsdf Projection Source # 
Instance details

Defined in Telescope.Asdf.GWCS

ToAsdf Rotate3d Source # 
Instance details

Defined in Telescope.Asdf.GWCS

ToAsdf SpectralFrame Source # 
Instance details

Defined in Telescope.Asdf.GWCS

ToAsdf StokesFrame Source # 
Instance details

Defined in Telescope.Asdf.GWCS

ToAsdf Transformation Source # 
Instance details

Defined in Telescope.Asdf.GWCS

ToAsdf DataType Source # 
Instance details

Defined in Telescope.Asdf.Class

ToAsdf NDArrayData Source # 
Instance details

Defined in Telescope.Asdf.Class

ToAsdf Node Source # 
Instance details

Defined in Telescope.Asdf.Class

ToAsdf Tree Source # 
Instance details

Defined in Telescope.Asdf.Class

ToAsdf Value Source # 
Instance details

Defined in Telescope.Asdf.Class

ToAsdf Text Source # 
Instance details

Defined in Telescope.Asdf.Class

ToAsdf UTCTime Source # 
Instance details

Defined in Telescope.Asdf.Class

ToAsdf String Source # 
Instance details

Defined in Telescope.Asdf.Class

ToAsdf Integer Source # 
Instance details

Defined in Telescope.Asdf.Class

ToAsdf Bool Source # 
Instance details

Defined in Telescope.Asdf.Class

ToAsdf Double Source # 
Instance details

Defined in Telescope.Asdf.Class

ToAsdf Float Source # 
Instance details

Defined in Telescope.Asdf.Class

ToAsdf Int Source # 
Instance details

Defined in Telescope.Asdf.Class

ToAsdf a => ToAsdf (NonEmpty a) Source # 
Instance details

Defined in Telescope.Asdf.Class

ToAsdf as => ToAsdf (CompositeFrame as) Source # 
Instance details

Defined in Telescope.Asdf.GWCS

ToAsdf frame => ToAsdf (GWCSStep frame) Source # 
Instance details

Defined in Telescope.Asdf.GWCS

ToAsdf (Axes 'Row) Source # 
Instance details

Defined in Telescope.Asdf.Class

ToAsdf a => ToAsdf (Maybe a) Source # 
Instance details

Defined in Telescope.Asdf.Class

ToAsdf a => ToAsdf [a] Source # 
Instance details

Defined in Telescope.Asdf.Class

Methods

toValue :: [a] -> Value Source #

schema :: [a] -> SchemaTag Source #

anchor :: [a] -> Maybe Anchor Source #

toNode :: [a] -> Node Source #

(ToAsdf inp, ToAsdf out) => ToAsdf (GWCS inp out) Source # 
Instance details

Defined in Telescope.Asdf.GWCS

Methods

toValue :: GWCS inp out -> Value Source #

schema :: GWCS inp out -> SchemaTag Source #

anchor :: GWCS inp out -> Maybe Anchor Source #

toNode :: GWCS inp out -> Node Source #

ToAsdf (Linear a) Source # 
Instance details

Defined in Telescope.Asdf.GWCS

ToAsdf (Scale a) Source # 
Instance details

Defined in Telescope.Asdf.GWCS

ToAsdf (Shift a) Source # 
Instance details

Defined in Telescope.Asdf.GWCS

(ToAsdf a, ToAsdf b) => ToAsdf (a, b) Source # 
Instance details

Defined in Telescope.Asdf.Class

Methods

toValue :: (a, b) -> Value Source #

schema :: (a, b) -> SchemaTag Source #

anchor :: (a, b) -> Maybe Anchor Source #

toNode :: (a, b) -> Node Source #

(BinaryValue a, IsDataType a, Prim a, AxesIndex ix, PutArray ix) => ToAsdf (Array D ix a) Source # 
Instance details

Defined in Telescope.Asdf.Class

Methods

toValue :: Array D ix a -> Value Source #

schema :: Array D ix a -> SchemaTag Source #

anchor :: Array D ix a -> Maybe Anchor Source #

toNode :: Array D ix a -> Node Source #

(ToAsdf a, ToAsdf b, ToAsdf c) => ToAsdf (a, b, c) Source # 
Instance details

Defined in Telescope.Asdf.Class

Methods

toValue :: (a, b, c) -> Value Source #

schema :: (a, b, c) -> SchemaTag Source #

anchor :: (a, b, c) -> Maybe Anchor Source #

toNode :: (a, b, c) -> Node Source #

(ToAsdf a, ToAsdf b, ToAsdf c, ToAsdf d) => ToAsdf (a, b, c, d) Source # 
Instance details

Defined in Telescope.Asdf.Class

Methods

toValue :: (a, b, c, d) -> Value Source #

schema :: (a, b, c, d) -> SchemaTag Source #

anchor :: (a, b, c, d) -> Maybe Anchor Source #

toNode :: (a, b, c, d) -> Node Source #

class FromAsdf a where Source #

Parse an Asdf Value or Node into a type. The generic instance will decode an Object with field names matching record selectors

data Example = Example
  { name :: Text
  , age :: Int
  , tags :: [Text]
  }
  deriving (Generic, FromAsdf)

Minimal complete definition

Nothing

Methods

parseValue :: forall (es :: [Effect]). Parser :> es => Value -> Eff es a Source #

Specify how a type is parsed from a Value

instance FromAsdf Integer where
  parseValue = \case
    Integer n -> pure $ fromIntegral n
    node -> expected "Integer" node

default parseValue :: forall (es :: [Effect]). (Generic a, GParseObject (Rep a), Parser :> es) => Value -> Eff es a Source #

Instances

Instances details
FromAsdf ByteOrder Source # 
Instance details

Defined in Telescope.Asdf.Class

Methods

parseValue :: forall (es :: [Effect]). Parser :> es => Value -> Eff es ByteOrder Source #

FromAsdf Int16 Source # 
Instance details

Defined in Telescope.Asdf.Class

Methods

parseValue :: forall (es :: [Effect]). Parser :> es => Value -> Eff es Int16 Source #

FromAsdf Int32 Source # 
Instance details

Defined in Telescope.Asdf.Class

Methods

parseValue :: forall (es :: [Effect]). Parser :> es => Value -> Eff es Int32 Source #

FromAsdf Int64 Source # 
Instance details

Defined in Telescope.Asdf.Class

Methods

parseValue :: forall (es :: [Effect]). Parser :> es => Value -> Eff es Int64 Source #

FromAsdf Int8 Source # 
Instance details

Defined in Telescope.Asdf.Class

Methods

parseValue :: forall (es :: [Effect]). Parser :> es => Value -> Eff es Int8 Source #

FromAsdf Asdf Source # 
Instance details

Defined in Telescope.Asdf.Core

Methods

parseValue :: forall (es :: [Effect]). Parser :> es => Value -> Eff es Asdf Source #

FromAsdf ExtensionMetadata Source # 
Instance details

Defined in Telescope.Asdf.Core

Methods

parseValue :: forall (es :: [Effect]). Parser :> es => Value -> Eff es ExtensionMetadata Source #

FromAsdf History Source # 
Instance details

Defined in Telescope.Asdf.Core

Methods

parseValue :: forall (es :: [Effect]). Parser :> es => Value -> Eff es History Source #

FromAsdf Quantity Source # 
Instance details

Defined in Telescope.Asdf.Core

Methods

parseValue :: forall (es :: [Effect]). Parser :> es => Value -> Eff es Quantity Source #

FromAsdf Software Source # 
Instance details

Defined in Telescope.Asdf.Core

Methods

parseValue :: forall (es :: [Effect]). Parser :> es => Value -> Eff es Software Source #

FromAsdf Unit Source # 
Instance details

Defined in Telescope.Asdf.Core

Methods

parseValue :: forall (es :: [Effect]). Parser :> es => Value -> Eff es Unit Source #

FromAsdf DataType Source # 
Instance details

Defined in Telescope.Asdf.Class

Methods

parseValue :: forall (es :: [Effect]). Parser :> es => Value -> Eff es DataType Source #

FromAsdf NDArrayData Source # 
Instance details

Defined in Telescope.Asdf.Class

Methods

parseValue :: forall (es :: [Effect]). Parser :> es => Value -> Eff es NDArrayData Source #

FromAsdf Node Source # 
Instance details

Defined in Telescope.Asdf.Class

Methods

parseValue :: forall (es :: [Effect]). Parser :> es => Value -> Eff es Node Source #

FromAsdf Tree Source # 
Instance details

Defined in Telescope.Asdf.Class

Methods

parseValue :: forall (es :: [Effect]). Parser :> es => Value -> Eff es Tree Source #

FromAsdf Value Source # 
Instance details

Defined in Telescope.Asdf.Class

Methods

parseValue :: forall (es :: [Effect]). Parser :> es => Value -> Eff es Value Source #

FromAsdf Text Source # 
Instance details

Defined in Telescope.Asdf.Class

Methods

parseValue :: forall (es :: [Effect]). Parser :> es => Value -> Eff es Text Source #

FromAsdf UTCTime Source # 
Instance details

Defined in Telescope.Asdf.Class

Methods

parseValue :: forall (es :: [Effect]). Parser :> es => Value -> Eff es UTCTime Source #

FromAsdf String Source # 
Instance details

Defined in Telescope.Asdf.Class

Methods

parseValue :: forall (es :: [Effect]). Parser :> es => Value -> Eff es String Source #

FromAsdf Integer Source # 
Instance details

Defined in Telescope.Asdf.Class

Methods

parseValue :: forall (es :: [Effect]). Parser :> es => Value -> Eff es Integer Source #

FromAsdf Bool Source # 
Instance details

Defined in Telescope.Asdf.Class

Methods

parseValue :: forall (es :: [Effect]). Parser :> es => Value -> Eff es Bool Source #

FromAsdf Double Source # 
Instance details

Defined in Telescope.Asdf.Class

Methods

parseValue :: forall (es :: [Effect]). Parser :> es => Value -> Eff es Double Source #

FromAsdf Float Source # 
Instance details

Defined in Telescope.Asdf.Class

Methods

parseValue :: forall (es :: [Effect]). Parser :> es => Value -> Eff es Float Source #

FromAsdf Int Source # 
Instance details

Defined in Telescope.Asdf.Class

Methods

parseValue :: forall (es :: [Effect]). Parser :> es => Value -> Eff es Int Source #

FromAsdf a => FromAsdf (NonEmpty a) Source # 
Instance details

Defined in Telescope.Asdf.Class

Methods

parseValue :: forall (es :: [Effect]). Parser :> es => Value -> Eff es (NonEmpty a) Source #

FromAsdf a => FromAsdf (Maybe a) Source # 
Instance details

Defined in Telescope.Asdf.Class

Methods

parseValue :: forall (es :: [Effect]). Parser :> es => Value -> Eff es (Maybe a) Source #

FromAsdf [Int16] Source # 
Instance details

Defined in Telescope.Asdf.Class

Methods

parseValue :: forall (es :: [Effect]). Parser :> es => Value -> Eff es [Int16] Source #

FromAsdf [Int32] Source # 
Instance details

Defined in Telescope.Asdf.Class

Methods

parseValue :: forall (es :: [Effect]). Parser :> es => Value -> Eff es [Int32] Source #

FromAsdf [Int64] Source # 
Instance details

Defined in Telescope.Asdf.Class

Methods

parseValue :: forall (es :: [Effect]). Parser :> es => Value -> Eff es [Int64] Source #

FromAsdf [Int8] Source # 
Instance details

Defined in Telescope.Asdf.Class

Methods

parseValue :: forall (es :: [Effect]). Parser :> es => Value -> Eff es [Int8] Source #

FromAsdf [Text] Source # 
Instance details

Defined in Telescope.Asdf.Class

Methods

parseValue :: forall (es :: [Effect]). Parser :> es => Value -> Eff es [Text] Source #

FromAsdf [Double] Source # 
Instance details

Defined in Telescope.Asdf.Class

Methods

parseValue :: forall (es :: [Effect]). Parser :> es => Value -> Eff es [Double] Source #

FromAsdf [Int] Source # 
Instance details

Defined in Telescope.Asdf.Class

Methods

parseValue :: forall (es :: [Effect]). Parser :> es => Value -> Eff es [Int] Source #

FromAsdf a => FromAsdf [a] Source # 
Instance details

Defined in Telescope.Asdf.Class

Methods

parseValue :: forall (es :: [Effect]). Parser :> es => Value -> Eff es [a] Source #

(FromAsdf a, FromAsdf b) => FromAsdf (a, b) Source # 
Instance details

Defined in Telescope.Asdf.Class

Methods

parseValue :: forall (es :: [Effect]). Parser :> es => Value -> Eff es (a, b) Source #

(BinaryValue a, Prim a, AxesIndex ix) => FromAsdf (Array D ix a) Source # 
Instance details

Defined in Telescope.Asdf.Class

Methods

parseValue :: forall (es :: [Effect]). Parser :> es => Value -> Eff es (Array D ix a) Source #

(FromAsdf a, FromAsdf b, FromAsdf c) => FromAsdf (a, b, c) Source # 
Instance details

Defined in Telescope.Asdf.Class

Methods

parseValue :: forall (es :: [Effect]). Parser :> es => Value -> Eff es (a, b, c) Source #

(FromAsdf a, FromAsdf b, FromAsdf c, FromAsdf d) => FromAsdf (a, b, c, d) Source # 
Instance details

Defined in Telescope.Asdf.Class

Methods

parseValue :: forall (es :: [Effect]). Parser :> es => Value -> Eff es (a, b, c, d) Source #

parseInteger :: forall a (es :: [Effect]). (Integral a, Parser :> es) => Value -> Eff es a Source #

parseAnyList :: forall a (es :: [Effect]). (FromAsdf a, FromNDArray [a], Parser :> es) => Value -> Eff es [a] Source #

Flexibly parse lists from either Array or NDArray

parseNode :: forall a (es :: [Effect]). (FromAsdf a, Parser :> es) => Node -> Eff es a Source #

Parse a node, ignoring the schema tag

(.:) :: forall a (es :: [Effect]). (FromAsdf a, Parser :> es) => Object -> Key -> Eff es a Source #

Parse a key from an Object

instance FromAsdf User where
  parseValue = \case
    Object o -> do
      name <- o .: "name"
      age <- o .: "age"
      pure $ User{name, age}

(.:?) :: forall a (es :: [Effect]). (FromAsdf a, Parser :> es) => Object -> Key -> Eff es (Maybe a) Source #

Parse an optional key from an Object

(!) :: forall a (es :: [Effect]). (FromAsdf a, Parser :> es) => [Node] -> Int -> Eff es a Source #

Parse a child at the given array index - > instance FromAsdf Friends where > parseValue = case > Array ns -> do > best <- ns ! 0 > second <- ns ! 1 > other <- mapM parseNode ns > pure $ Friends{best, second, other}

class GToObject (f :: k -> Type) where Source #

Generically serialize records to an Object

Methods

gToObject :: forall (p :: k). f p -> Object Source #

Instances

Instances details
(GToObject f, GToObject g) => GToObject (f :*: g :: k -> Type) Source # 
Instance details

Defined in Telescope.Asdf.Class

Methods

gToObject :: forall (p :: k). (f :*: g) p -> Object Source #

GToObject f => GToObject (M1 C c f :: k -> Type) Source # 
Instance details

Defined in Telescope.Asdf.Class

Methods

gToObject :: forall (p :: k). M1 C c f p -> Object Source #

GToObject f => GToObject (M1 D c f :: k -> Type) Source # 
Instance details

Defined in Telescope.Asdf.Class

Methods

gToObject :: forall (p :: k). M1 D c f p -> Object Source #

(GToNode f, Selector s) => GToObject (M1 S s f :: k -> Type) Source # 
Instance details

Defined in Telescope.Asdf.Class

Methods

gToObject :: forall (p :: k). M1 S s f p -> Object Source #

class GToNode (f :: k -> Type) where Source #

Generically serialize record values to a Node

Methods

gToNode :: forall (p :: k). f p -> Node Source #

Instances

Instances details
ToAsdf a => GToNode (K1 R (Maybe a) :: k -> Type) Source # 
Instance details

Defined in Telescope.Asdf.Class

Methods

gToNode :: forall (p :: k). K1 R (Maybe a) p -> Node Source #

ToAsdf a => GToNode (K1 R a :: k -> Type) Source # 
Instance details

Defined in Telescope.Asdf.Class

Methods

gToNode :: forall (p :: k). K1 R a p -> Node Source #

class GParseObject (f :: k -> Type) where Source #

Generically parse Objects into records

Methods

gParseObject :: forall (es :: [Effect]) (p :: k). Parser :> es => Object -> Eff es (f p) Source #

Instances

Instances details
(GParseObject f, GParseObject g) => GParseObject (f :*: g :: k -> Type) Source # 
Instance details

Defined in Telescope.Asdf.Class

Methods

gParseObject :: forall (es :: [Effect]) (p :: k). Parser :> es => Object -> Eff es ((f :*: g) p) Source #

GParseObject f => GParseObject (M1 C c f :: k -> Type) Source # 
Instance details

Defined in Telescope.Asdf.Class

Methods

gParseObject :: forall (es :: [Effect]) (p :: k). Parser :> es => Object -> Eff es (M1 C c f p) Source #

GParseObject f => GParseObject (M1 D c f :: k -> Type) Source # 
Instance details

Defined in Telescope.Asdf.Class

Methods

gParseObject :: forall (es :: [Effect]) (p :: k). Parser :> es => Object -> Eff es (M1 D c f p) Source #

(GParseKey f, Selector s) => GParseObject (M1 S s f :: k -> Type) Source # 
Instance details

Defined in Telescope.Asdf.Class

Methods

gParseObject :: forall (es :: [Effect]) (p :: k). Parser :> es => Object -> Eff es (M1 S s f p) Source #

class GParseKey (f :: k -> Type) where Source #

Generically parse a key from an Object into a record value

Methods

gParseKey :: forall (es :: [Effect]) (p :: k). Parser :> es => Object -> Key -> Eff es (f p) Source #

Instances

Instances details
FromAsdf a => GParseKey (K1 R (Maybe a) :: k -> Type) Source # 
Instance details

Defined in Telescope.Asdf.Class

Methods

gParseKey :: forall (es :: [Effect]) (p :: k). Parser :> es => Object -> Key -> Eff es (K1 R (Maybe a) p) Source #

FromAsdf a => GParseKey (K1 R a :: k -> Type) Source # 
Instance details

Defined in Telescope.Asdf.Class

Methods

gParseKey :: forall (es :: [Effect]) (p :: k). Parser :> es => Object -> Key -> Eff es (K1 R a p) Source #