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:  crypto random UUID generation (David McBride)
   2.  Problem install Gtk (Arnim Fiebig)
   3.  Sorting (mike h)


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

Message: 1
Date: Tue, 13 Dec 2016 08:18:05 -0500
From: David McBride <toa...@gmail.com>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <beginners@haskell.org>
Subject: Re: [Haskell-beginners] crypto random UUID generation
Message-ID:
        <CAN+Tr42_C+T5mUHsLkmPuAh0+U=smm1qrucaf9vjh1jgk5s...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

I was hasty with my words.  Exceptions in haskell have always been my
cryptonite.  If you are handling the only known exception properly then you
are doing everything right.

On Tue, Dec 13, 2016 at 6:41 AM, Ovidiu Deac <ovidiud...@gmail.com> wrote:

> Thanks! It works.
>
> Why is this a "quick and dirty" fix and what would be the "clean" fix?
>
> On Mon, Dec 12, 2016 at 8:15 PM, David McBride <toa...@gmail.com> wrote:
>
>> The problem is with
>>   Left err -> throwIO err
>>
>> Because of the type of 'runCRand', we know err is an instance of
>> ContainsGenError e0, but which one?  We need a concrete error type before
>> we can run this code.  Looking at the docs there seems to be only one
>> instance of ContainsGenError, GenError, so a quick an dirty solution would
>> be to change it to
>>
>>   Left err -> throwIO (err :: GenError) -- should work
>>
>> But keep in mind, if there were any other ContainsGenError instances,
>> like from an external library that is adding a new type of random generator
>> to this library that fails in a new way, you would not be catching that.
>>
>>
>> On Mon, Dec 12, 2016 at 12:52 PM, Ovidiu Deac <ovidiud...@gmail.com>
>> wrote:
>>
>>> I have to produce a crypto random UUID.
>>>
>>> I haven't found simple examples. and I used the one from hre (see type
>>> CRand) http://hackage.haskell.org/package/monadcryptorandom-0.7.0/d
>>> ocs/Control-Monad-CryptoRandom.html#v:getCRandomR
>>>
>>> My attempt is the following:
>>>
>>> cryptoRandomUUID :: IO UUID.UUID
>>> cryptoRandomUUID = do
>>>   g <- newGenIO:: IO SystemRandom
>>>   case runCRand impl g of
>>>     Left err -> throwIO err
>>>     Right (v, g') -> return v
>>>
>>>   where impl = do
>>>           w1 <- getCRandom
>>>           w2 <- getCRandom
>>>           w3 <- getCRandom
>>>           w4 <- getCRandom
>>>           return $ UUID.fromWords w1 w2 w3 w4
>>>
>>> ...but the compilation fails miserably with:
>>>
>>>     • Ambiguous type variable ‘e0’ arising from a use of ‘runCRand’
>>>       prevents the constraint ‘(ContainsGenError e0)’ from being solved.
>>>       Relevant bindings include
>>>         impl :: CRandT
>>>                   SystemRandom e0 Data.Functor.Identity.Identity
>>> UUID.UUID
>>>           (bound at src/Party.hs:75:9)
>>>       Probable fix: use a type annotation to specify what ‘e0’ should be.
>>>       These potential instance exist:
>>>         instance ContainsGenError GenError
>>>           -- Defined in ‘Control.Monad.CryptoRandom’
>>>     • In the expression: runCRand impl g
>>>       In a stmt of a 'do' block:
>>>         case runCRand impl g of {
>>>           Left err -> throwIO err
>>>           Right (v, g') -> return v }
>>>       In the expression:
>>>         do { g <- newGenIO :: IO SystemRandom;
>>>              case runCRand impl g of {
>>>                Left err -> throwIO err
>>>                Right (v, g') -> return v } }
>>>       ...
>>>
>>> What's the problem here?
>>> Are there some good examples for generating crypto-randoms?
>>>
>>> Thanks!
>>>
>>> _______________________________________________
>>> Beginners mailing list
>>> Beginners@haskell.org
>>> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>>>
>>>
>>
>> _______________________________________________
>> Beginners mailing list
>> Beginners@haskell.org
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>>
>>
>
> _______________________________________________
> Beginners mailing list
> Beginners@haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20161213/bc825b09/attachment-0001.html>

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

Message: 2
Date: Tue, 13 Dec 2016 14:23:46 +0100
From: Arnim Fiebig <guenter.fie...@online.de>
To: beginners@haskell.org
Subject: [Haskell-beginners] Problem install Gtk
Message-ID: <2baa189e-2214-f7a9-d7b9-465119c17...@online.de>
Content-Type: text/plain; charset="utf-8"; Format="flowed"

The same happen on Win8.1 and another Pc with win7


1. install 'HaskellPlatform-8.0.1-full-x86_64-setup-a'         ok

2. copy 'gtk+-bundle_3.6.4-20130513_win64' to C:\Gtk\             ok

3. 'cabal install gtk'                                 failed


Thanks for help
Guenter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20161213/61da7db1/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: phjidiombkcgeenh.gif
Type: image/gif
Size: 8169 bytes
Desc: not available
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20161213/61da7db1/attachment-0001.gif>

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

Message: 3
Date: Tue, 13 Dec 2016 14:36:39 +0000
From: mike h <mike_k_hough...@yahoo.co.uk>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <beginners@haskell.org>
Subject: [Haskell-beginners] Sorting
Message-ID: <53cf400d-2321-4b29-a4da-77d481d5f...@yahoo.co.uk>
Content-Type: text/plain; charset="utf-8"

Hi,

I’m trying to sort a list of tuples. A char and a count of that char (Char , 
Int) 
e.g.

[ ('r',2), ('c',2),('a', 2), ('b',3), ('f',2)]

e.g. ‘r’ occurs twice etc.
The order should be based on the count first and then ties broken by the 
natural ordering of char.
So 
[ ('r',2), ('c',2),('a', 2), ('b',3), ('f',2)]

will sort as

[('b',3),('a', 2), ('c',2),('f',2), ('r',2)]

I initially tried variants on
sortBy (compare `on` snd)

and then made a type Tup = T (Char, Int)
and defined Eq and then got to the point where I felt that this had become too 
difficult for a simple problem and concluded that I’m missing a point somewhere 
and need a bit of help!

Many thanks
M
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20161213/1418403f/attachment.html>

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

Subject: Digest Footer

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


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

End of Beginners Digest, Vol 102, Issue 2
*****************************************

Reply via email to