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. Re:  Export two modules from one.hs file? (Francesco Ariis)
   2. Re:  How to use the Data.Map inbuild Monoid (Simon Jakobi)


----------------------------------------------------------------------

Message: 1
Date: Mon, 18 Nov 2019 23:23:52 +0100
From: Francesco Ariis <fa...@ariis.it>
To: beginners@haskell.org
Subject: Re: [Haskell-beginners] Export two modules from one.hs file?
Message-ID: <20191118222039.ga9...@x60s.casa>
Content-Type: text/plain; charset=us-ascii

Hello Leonard,

On Mon, Nov 18, 2019 at 08:42:22PM +0000, Leonhard Applis wrote:
> I currently want to make a module, which "truly" exposes 3 functions.
> However, there are more functions which I want to test.
> I would like to export two modules from the same file, "ModuleToUse"
> and "ModuleOpen".

Unfortunately Haskell (rather, GHC) in its current incarnation does
not allow many-modules-per-single-file (which would indeed come quite
handy in cases like yours, in writing example code, etc.).

> What is the "real world" approach for this?

Have two modules, `Prova` and `Prova.Internal` (files:
`src/Prova.hs` and `src/Prova/Intenral.hs`).j

Does this answer your question?
-F


------------------------------

Message: 2
Date: Mon, 18 Nov 2019 23:48:06 +0100
From: Simon Jakobi <simon.jak...@googlemail.com>
To: Leonhard Applis <leonhard.app...@protonmail.com>,  The
        Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <beginners@haskell.org>
Subject: Re: [Haskell-beginners] How to use the Data.Map inbuild
        Monoid
Message-ID:
        <CAGtp2Sh=s7JOgeBE9+=fb8krps-chr4zd0zpqfzf76dsiyx...@mail.gmail.com>
Content-Type: text/plain; charset="UTF-8"

Hi Leonhard,

the monoidal-containers package should be interesting to you:

http://hackage.haskell.org/package/monoidal-containers

Cheers,
Simon

Am Mo., 18. Nov. 2019 um 23:22 Uhr schrieb Leonhard Applis
<leonhard.app...@protonmail.com>:
>
> Hello Francesco,
>
> > `Map k v` is already an instance of `Monoid` (when `v` is an instance of 
> > `Ord`), are you sure you need to write another one?
>
> Thanks for your answer!
> My "Values" is a Monoid, however it seems that the Graph cannot properly be 
> seen correctly as a Monoid
>
> using mconcat does not (properly) work, meaning that <> is not correctly 
> applied to the someMonoids
> so instead of
>
> type G = Map Text someMonoid
> mconcat [gs]
>
> I have to write:
>
> foldr (Map.unionWith (<>)) Map.empty [gs]
>
> This passes the tests.
> Same Problem with
> g1 <> g2  --(Does not work properly)
> and
> Map.unionWith (<>) g1 g2 --(Does work)
>
> I have declared someMonoid myself, do I need to declare something special 
> about it?
> I feel like my G is messing up with <> being about him, or about someMonoid
>
> A broken down piece of code is:
>
> import Data.Map as Map
>
> data Sum = Sum Int deriving (Eq,Show)
>
> instance Semigroup Sum where
>     (<>) (Sum a) (Sum b)= Sum(a + b)
> instance Monoid Sum where
>     mempty = Sum 0
>
> type G = Map.Map String Sum
>
> And to verify my problem:
> GHCI > v = Map.singleton "A" (Sum 1)
> GHCI > u = Map.singleton "A" (Sum 1)
> GHCI> c= v <> u
> GHCI> Map.lookup "A" c
> Just (Sum 1)
>
> but I want
> Just (Sum 2)
>
> thanks
> Leonhard
> _______________________________________________
> Beginners mailing list
> Beginners@haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners


------------------------------

Subject: Digest Footer

_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners


------------------------------

End of Beginners Digest, Vol 137, Issue 7
*****************************************

Reply via email to