Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org
You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than "Re: Contents of Beginners digest..." Today's Topics: 1. Using a monad function inside the monad transfomer variant (Moritz Tacke) 2. Re: Using a monad function inside the monad transfomer variant (Seph Shewell Brockway) 3. Parsing Terms in Brackets for Calculator (Leonhard Applis) ---------------------------------------------------------------------- Message: 1 Date: Fri, 1 Feb 2019 15:14:32 +0100 From: Moritz Tacke <moritz.ta...@gmail.com> To: beginners@haskell.org Subject: [Haskell-beginners] Using a monad function inside the monad transfomer variant Message-ID: <CANZtOB1riZq_TG8U9AghcX=7bh3k55bplzi0lzd4nn9nivl...@mail.gmail.com> Content-Type: text/plain; charset="UTF-8" Hi, I am running into difficulties regarding the use of monad transformers. The situation is as follows: I implemented some functions returning "RVar" results. Now, in a different part of the program, I am using STUArrays. Therefore my idea was to create a monad transformer stack which would have this type: someFunction:: a -> b -> RVarT (ST s) (STUArray s Int Double) I still want to use the functions that return RVars, so eg. rvarDouble :: RVar Double and then the definition of the transformer function would be: someFunction a b = do ... the_double <- rvarDouble .... This does not compile, complaining that; • Couldn't match type ‘Data.Functor.Identity.Identity’ with ‘ST s’ Expected type: RVarT (ST s) Double Actual type: RVar Double How can I re-user the RVar function in the RVarT monad transformer? Sincerely yours, Moritz ------------------------------ Message: 2 Date: Fri, 1 Feb 2019 17:57:17 +0000 From: Seph Shewell Brockway <s...@codex.scot> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] Using a monad function inside the monad transfomer variant Message-ID: <20190201175717.acbhtmqs2wv23c5p@leviathan> Content-Type: text/plain; charset=utf-8 On Fri, Feb 01, 2019 at 03:14:32PM +0100, Moritz Tacke wrote: > Hi, > > I still want to use the functions that return RVars, so eg. > > rvarDouble :: RVar Double > > and then the definition of the transformer function would be: > > someFunction a b = > do ... > the_double <- rvarDouble > .... > > This does not compile, complaining that; > > • Couldn't match type ‘Data.Functor.Identity.Identity’ with ‘ST s’ > Expected type: RVarT (ST s) Double > Actual type: RVar Double > > How can I re-user the RVar function in the RVarT monad transformer? Your declaration of rvarDouble needs to be polymorphic in the monad: rvarDouble :: Monad m => RVarT m Double The crucial observation is that RVar is actually a type synonym for RVarT Identity, so the function can still be made to return a plain RVar Double, but it can also return an RVarT (ST s) Double, satisfying the type-checker in the example that you gave. -- Seph Shewell Brockway, BSc MSc (Glas.) ------------------------------ Message: 3 Date: Sat, 02 Feb 2019 08:02:36 +0000 From: Leonhard Applis <leonhard.app...@protonmail.com> To: "beginners@haskell.org" <beginners@haskell.org> Subject: [Haskell-beginners] Parsing Terms in Brackets for Calculator Message-ID: <HTHwJeVSXkupBGrfRHdmRdsujghkho3j4A8VdAJUMJfSIkmsTWQOmmxxrkkCAL9G91vTkmPiQKyMvorN1Uo0N0TcEkDSDo6MiwdbMSba8UM=@protonmail.com> Content-Type: text/plain; charset="utf-8" Hello, I'm currently doing my first steps in Haskell with a calculator and I'm stuck at the parser. I have a data Term which will build ... basically a tree of operations, and works fine. I need help for the function termify :: [Either Operator Term] -> Term It takes operators (such as +,**) and terms and output a new, bigger term and is mostly trivial. However, all attempts I've done for parsing brackets seem very ... crude and not like Haskell at all. The very first pattern match should check for the innermost brackets, and return termify for everything in between. I guess that I'm missing some really cool, haskelly solution here. Best Regards Leonhard -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20190202/21208409/attachment-0001.html> ------------------------------ Subject: Digest Footer _______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners ------------------------------ End of Beginners Digest, Vol 128, Issue 1 *****************************************