All Downloads are FREE. Search and download functionalities are using the official Maven repository.

lucuma.itc.input.odb.FluxDensityInput.scala Maven / Gradle / Ivy

// Copyright (c) 2016-2023 Association of Universities for Research in Astronomy, Inc. (AURA)
// For license information see LICENSE or https://opensource.org/licenses/BSD-3-Clause

package lucuma.odb.graphql
package input
package sourceprofile

import cats.syntax.all.*
import eu.timepit.refined.types.numeric.PosBigDecimal
import grackle.Result
import lucuma.core.math.Wavelength
import lucuma.odb.graphql.binding.*

object FluxDensityInput {

  val Binding: Matcher[(Wavelength, PosBigDecimal)] =
    ObjectFieldsBinding.rmap {
      case List(
            WavelengthInput.Binding("wavelenth", rWavelength),
            BigDecimalBinding("density", rDensity)
          ) =>
        (rWavelength, rDensity).parTupled.flatMap { case (wavelength, density) =>
          PosBigDecimal.from(density) match {
            case Left(err) => Result.failure(err)
            case Right(v)  => Result((wavelength, v))
          }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy