Send Beginners mailing list submissions to
[email protected]
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
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. Re: importing Data.Digits (David McBride)
2. Export two modules from one.hs file? (Leonhard Applis)
3. How to use the Data.Map inbuild Monoid (Leonhard Applis)
----------------------------------------------------------------------
Message: 1
Date: Mon, 18 Nov 2019 08:11:30 -0500
From: David McBride <[email protected]>
To: Alexander Chen <[email protected]>, The Haskell-Beginners
Mailing List - Discussion of primarily beginner-level topics related
to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] importing Data.Digits
Message-ID:
<CAN+Tr42ngw5+cMFgb1DuknX4sVYMx2EdC_-eU=VtECw-_z=y...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
This particular module comes from a separate package. By default all
modules you use happen to be in the base package, which ships with ghc. To
use other libraries you must make a proper project which tells ghc which
libraries you are using. For example, the digits package uses this cabal
file at http://hackage.haskell.org/package/digits-0.3.1/digits.cabal
You can find more information about how to start a package from scratch
here https://www.haskell.org/cabal/users-guide/developing-packages.html
On Mon, Nov 18, 2019 at 7:31 AM Alexander Chen <[email protected]> wrote:
> Hi All,
>
> This is my first 'post' not quite sure if I am doing it right.
>
> I have a question about the importing of modules that are available on the
> Hackage.Haskell site:
> http://hackage.haskell.org/package/digits
>
> if I write this in my wordpad and then load it to GCI i get the following
> error:
>
>
> chapter4.hs:1:1: error:
> Could not find module ‘Data.Digits’
> Perhaps you meant Data.Bits (from base-4.12.0.0)
> Use -v to see a list of the files searched for.
> |
> 1 | import Data.Digits | ^^^^^^^^^^^^^^^^^^
>
>
> However if I load Data.Char than it loads fine.
>
> What am I doing wrong?
>
> best,
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20191118/e3c17e0d/attachment-0001.html>
------------------------------
Message: 2
Date: Mon, 18 Nov 2019 20:42:22 +0000
From: Leonhard Applis <[email protected]>
To: "[email protected]" <[email protected]>
Subject: [Haskell-beginners] Export two modules from one.hs file?
Message-ID:
<_QHLN6QYGGGjW3RwH0CJB2tIsuSBrKe3klqLJ45k_Kf-rUpFNV_XkUHLy38_V0e9byfWFK5nUDvfdSJ_xdoqhfx_XOwaeHUfzJz3q8QioSc=@protonmail.com>
Content-Type: text/plain; charset="utf-8"
Hey All,
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".
Then I can use ModuleToUse everywhere else, and ModuleOpen in the UnitTests.
I know I can declare ModuleOpen, and export only certain functions with
ModuleToUse.
But I am not sure, if that is a smart / normal thing to do. In my case this
would double my modules, and ... hence files?
What is the "real world" approach for this?
Thanks
Leonhard
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20191118/6f8bf15d/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: publickey - [email protected] - 0x807FDDF3.asc
Type: application/pgp-keys
Size: 1843 bytes
Desc: not available
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20191118/6f8bf15d/attachment-0001.key>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 477 bytes
Desc: OpenPGP digital signature
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20191118/6f8bf15d/attachment-0001.sig>
------------------------------
Message: 3
Date: Mon, 18 Nov 2019 22:22:01 +0000
From: Leonhard Applis <[email protected]>
To: "[email protected]" <[email protected]>
Subject: [Haskell-beginners] How to use the Data.Map inbuild Monoid
Message-ID:
<J22L_DenEOy4uzUcjKrUq9cydX30XVPZtf784lfkyH-e_HWIVz5hOKKx7QHsUSd8NIkMvHucC9ZV_X4Yl735QrnqnymZmTm3IqMV1G-pvno=@protonmail.com>
Content-Type: text/plain; charset="utf-8"
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 someMonoidsso 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:
importData.MapasMap
dataSum=SumIntderiving (Eq,Show)
instanceSemigroupSumwhere
(<>) (Sum a) (Sum b)=Sum(a + b)
instanceMonoidSumwhere
mempty =Sum0
typeG=Map.MapStringSum
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20191118/1a748dcd/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: publickey - [email protected] - 0x807FDDF3.asc
Type: application/pgp-keys
Size: 1843 bytes
Desc: not available
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20191118/1a748dcd/attachment.key>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 477 bytes
Desc: OpenPGP digital signature
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20191118/1a748dcd/attachment.sig>
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 137, Issue 6
*****************************************