From daniel.trstenjak at gmail.com Wed Jul 1 08:31:35 2020 From: daniel.trstenjak at gmail.com (Daniel Trstenjak) Date: Wed, 1 Jul 2020 10:31:35 +0200 Subject: [Haskell-beginners] How to structure an application? In-Reply-To: References: Message-ID: <20200701083135.GB3366@octa> Hi Tilmann, > wxApp :: (MonadReader Handle m, MonadIO m) => m () > wxApp = do >   ping -- this works, but I don't need it here.. >   liftIO $ do >     f <- frame [ ] >     timer f [ interval := 1000 >             -- , on command := hputStrLn h "ping" -- this is what I try > to avoid >             -- , on command := ping -- of course, this doesn't work, but > it would be so nice.. >             , enabled := True] >     return () I assume that WX expects an 'IO' action for the 'command', but 'ping' is an action of the 'ReaderT' monad. WX won't be able to execute this action, because it doesn't know anything about the 'ReaderT' monad, so there's no 'Handle' that it could give to the 'ping' function. I think the most straight forward solution is to have a function 'ping': ping :: Handle -> IO () ping h = hputStrLn h "ping" And then a 'wxApp' like: wxApp :: (MonadReader Handle m, MonadIO m) => m () wxApp = do handle <- ask   liftIO $ do     f <- frame [ ]     timer f [ interval := 1000, on command := ping handle, enabled := True]     return () So instead of having 'ping' in the 'ReaderT' monad you just give it explicitly the data of the monad. You could have a helper function that does this transformation: handlize :: (MonadReader Handle m, MonadIO m) => (Handle -> IO()) -> m (IO ()) handlize func = do handle <- ask return $ func handle wxApp :: (MonadReader Handle m, MonadIO m) => m () wxApp = do cmd <- handlize ping   liftIO $ do     f <- frame [ ]     timer f [ interval := 1000, on command := cmd, enabled := True]     return () Greetings, Daniel From sudaraka at sudaraka.org Tue Jul 28 08:11:33 2020 From: sudaraka at sudaraka.org (Sudaraka Wijesinghe) Date: Tue, 28 Jul 2020 13:41:33 +0530 Subject: [Haskell-beginners] Need help setting up development environment via ghcup Message-ID: <20200728081142.DE586328005D@mailuser.nyi.internal> Hi, I have successfully installed `ghc` (8.8.4), `cabal-install` (3.2.0.0) via `ghcup` (0.1.8) and created/build and several example projects without any issues. In one of the projects I want to create a binary distribution tarball. For this I tried using `runhaskell Setup.hs copy` (configure before that) at one of the steps, and got the following error. ``` Configuring my-project-0.1.0.0... Setup.hs: Encountered missing or private dependencies: optparse-applicative ==0.15.* ``` `optparse-applicative` is a dependency of my project and it was installed by `cabal build`. I figured out this is because `cabal-install` and `runhaskell` (or `ghc` or `ghc-pkg`) used different package DBs. - `cabal-install` -> ~/.cabal/store/ghc-8.8.4/ - `runhaskell` -> ~/.ghcup/ghc/8.8.4/lib/ghc-8.8.4/ Is there a was I can make both `cabal-install` and `runhaskell` use the same package DB (or use both of them)? [X-POST: https://www.reddit.com/r/haskellquestions/comments/hydge5/need_help_setting_up_development_environment_via/] -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 833 bytes Desc: OpenPGP digital signature URL: