Git Product home page Git Product logo

Comments (4)

mrkkrp avatar mrkkrp commented on August 28, 2024

I would do all transformations on ByteStrings. You could actually use the newer modern-uri package for stripping fragments/etc. Then you just parse/detect whether the scheme is http or https right before performing actual HTTP request.

There are two ways to do that:

  1. If you go with modern-uri, you could just check the uriScheme component and dispatch on that.
  2. You could try running both parseUrlHttp and parseUrlHttps on the same URL. Only one of them will succeed (return something in Just). Then you pattern-match on that and send the request.

The type of HTTP response is the same for both schemes, so after the request you can merge the control flow back.

Sorry for troubles, but this is just the flip side of the libraries with strong static guarantees. They become less-handy in more dynamic situations. Even things like Servant suffer from this.

from req.

mrkkrp avatar mrkkrp commented on August 28, 2024

Did my answer help? Feel free to ask questions if something is not clear!

from req.

mrkkrp avatar mrkkrp commented on August 28, 2024

Closing due to the lack of response. Feel free to re-open if necessary.

from req.

hazelweakly avatar hazelweakly commented on August 28, 2024

Sorry for not replying! Your answer helped quite a lot, I just haven't had a lot of spare time lately to tinker on things (It's Finals week this week). It's been fun understanding better the balance between the strength of types and allowing enough freedom to do what you want. If you're curious, you can see the (super ugly, rough draft) of what I have so far in my urlchecker repo. It's in quite a state of disarray right now since I was trying a few things out and never cleaned it back up, so fair warning :p

from req.

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.