Code Monkey home page Code Monkey logo

Comments (4)

dmjio avatar dmjio commented on May 29, 2024

Ah, this is super interesting. Yea I don't see why not. Previously I've always just initialized the manager inside of FromEnv since there is a MonadIO instance. But your way seems to be a nice clever use of types.

instance Var () where
  toVar = const "()"
  fromVar = const $ Just ()

from envy.

tfausak avatar tfausak commented on May 29, 2024

Ah, I didn't know about the MonadIO instance because the Parser data type isn't exported. Regardless, if you do that you'll have to use undefined (or error or unsafePerformIO) in defConfig.

from envy.

dmjio avatar dmjio commented on May 29, 2024

Right, if you use liftIO in FromEnv, the assumption is that you're no longer using generics. But I can definitely see a case where you'd like to parse the environment w/o initializing connection pools, and the Var () approach seems pretty nice. Before, I'd have to do something like this.

instance FromEnv Config where
  fromEnv = do
    Config <$> liftIO createConPool 
           <*> envMaybe "PG_PORT" .!= 5432

But again, I can see a case for not wanting to do this, and initializing the connection pool at a later stage.

from envy.

dmjio avatar dmjio commented on May 29, 2024

@tfausak, and yea, Parser (minus constructors), should probably be exported.

from envy.

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.