Giter Site home page Giter Site logo

Comments (3)

KacperFKorban avatar KacperFKorban commented on August 28, 2024

Now that I think about it. Returning Either[String, ...] doesn't make that much sense. There is no good feedback loop in the form. It would only be able to return the error when submitting the form, so it is no different than verifying the input in the function implementation. Unless of course, we compile the type classes separately to js functions using Scala.js and attach them to the generated site. I don't have any good ideas on how to do that though. (Other than running scala-cli during site generation, which seems like a HUGE hack)

from guinep.

KacperFKorban avatar KacperFKorban commented on August 28, 2024

A decent idea is to define a decoder as

trait Decoder[-I, O]:
  def decide(I: I): O

Then we can summon Decoder[Nothing, T] in the macro generated code. (If we can manage to get that to work) Or maybe we can make I a type member instead.

Then based on the I we can figure out the field type, probably.

Not sure how to handle dropdowns with this encoding though. Maybe the I type should only ever be an internal InputType? Or maybe just add a field to the type class that defines the input field type?

e.g.

trait Decoder[O]:
  type I <: InputType
  def decide(I: InType[I]): O

(This might have to be on the term level)

from guinep.

KacperFKorban avatar KacperFKorban commented on August 28, 2024

One implementation detail for implementing this is that the generated code should change the eithers into exceptions, apply the function to the arguments extracted from the eithers and optionally catch the exceptions.

from guinep.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.