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:  is this not a better way ? data structure (Rein Henrichs)
   2.  Opaque (to me) compilation error (Dan Stromberg)
   3. Re:  Opaque (to me) compilation error (Theodore Lief Gannon)
   4. Re:  Opaque (to me) compilation error (Theodore Lief Gannon)
   5. Re:  Opaque (to me) compilation error (Kim-Ee Yeoh)


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

Message: 1
Date: Fri, 13 Nov 2015 13:32:35 -0800
From: Rein Henrichs <rein.henri...@gmail.com>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <beginners@haskell.org>
Subject: Re: [Haskell-beginners] is this not a better way ? data
        structure
Message-ID:
        
<m2lha1fuvg.fsf@Reins-MacBook.local.i-did-not-set--mail-host-address--so-tickle-me>
        
Content-Type: text/plain; charset="us-ascii"

As an aside, don't use ~Float~. Unless you have a specific reason to
want a half-precision floating point type, you should use ~Double~.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20151113/3b87faae/attachment-0001.html>

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

Message: 2
Date: Fri, 13 Nov 2015 17:41:45 -0800
From: Dan Stromberg <strom...@gmail.com>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <beginners@haskell.org>
Subject: [Haskell-beginners] Opaque (to me) compilation error
Message-ID:
        <caovkw57574u3nq0sc+ejr_clstnwx2rgfowwvwglcqzmvt5...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

In the following code:
prefix_md5 :: String -> Data.ByteString.ByteString
prefix_md5 filename = do
    let prefix_length = 1024
    file <- System.IO.openBinaryFile filename System.IO.ReadMode :: (IO
System.IO.Handle)
    data_read <- Data.ByteString.hGet file prefix_length :: (IO
Data.ByteString.ByteString)
    _ <- System.IO.hClose file
    let hasher = Crypto.Hash.MD5.init :: Crypto.Hash.MD5.Ctx
    let hasher2 = Crypto.Hash.MD5.update hasher data_read ::
Crypto.Hash.MD5.Ctx
    let digest = Crypto.Hash.MD5.finalize hasher2 ::
Data.ByteString.ByteString
    return digest :: (IO Data.ByteString.ByteString)

I get the error:
Md5s.hs:13:5:
    Couldn't match type `IO Data.ByteString.ByteString'
                  with `Data.ByteString.ByteString'
    Expected type: IO System.IO.Handle
                   -> (System.IO.Handle -> IO Data.ByteString.ByteString)
                   -> Data.ByteString.ByteString
      Actual type: IO System.IO.Handle
                   -> (System.IO.Handle -> IO Data.ByteString.ByteString)
                   -> IO Data.ByteString.ByteString
    In a stmt of a 'do' block:
      file <- System.IO.openBinaryFile filename System.IO.ReadMode ::
                IO System.IO.Handle

How should I interpret that error to solve this kind of problem on my own
in the future?  I don't see where the line in question does anything with
ByteString's!

How might I correct this function to eliminate the error?

Thanks!

-- 
Dan Stromberg
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20151113/1e3eecfa/attachment-0001.html>

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

Message: 3
Date: Fri, 13 Nov 2015 21:24:24 -0500
From: Theodore Lief Gannon <tan...@gmail.com>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <beginners@haskell.org>
Subject: Re: [Haskell-beginners] Opaque (to me) compilation error
Message-ID:
        <cajopsuctuurswxmx7et_38rwoouejcggwxuxcicgfjzmjrb...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

You're missing IO in the type declaration, which I believe means that do
block is running in the Id monad -- by inference, Id ByteString.

On Fri, Nov 13, 2015 at 8:41 PM, Dan Stromberg <strom...@gmail.com> wrote:

>
> In the following code:
> prefix_md5 :: String -> Data.ByteString.ByteString
> prefix_md5 filename = do
>     let prefix_length = 1024
>     file <- System.IO.openBinaryFile filename System.IO.ReadMode :: (IO
> System.IO.Handle)
>     data_read <- Data.ByteString.hGet file prefix_length :: (IO
> Data.ByteString.ByteString)
>     _ <- System.IO.hClose file
>     let hasher = Crypto.Hash.MD5.init :: Crypto.Hash.MD5.Ctx
>     let hasher2 = Crypto.Hash.MD5.update hasher data_read ::
> Crypto.Hash.MD5.Ctx
>     let digest = Crypto.Hash.MD5.finalize hasher2 ::
> Data.ByteString.ByteString
>     return digest :: (IO Data.ByteString.ByteString)
>
> I get the error:
> Md5s.hs:13:5:
>     Couldn't match type `IO Data.ByteString.ByteString'
>                   with `Data.ByteString.ByteString'
>     Expected type: IO System.IO.Handle
>                    -> (System.IO.Handle -> IO Data.ByteString.ByteString)
>                    -> Data.ByteString.ByteString
>       Actual type: IO System.IO.Handle
>                    -> (System.IO.Handle -> IO Data.ByteString.ByteString)
>                    -> IO Data.ByteString.ByteString
>     In a stmt of a 'do' block:
>       file <- System.IO.openBinaryFile filename System.IO.ReadMode ::
>                 IO System.IO.Handle
>
> How should I interpret that error to solve this kind of problem on my own
> in the future?  I don't see where the line in question does anything with
> ByteString's!
>
> How might I correct this function to eliminate the error?
>
> Thanks!
>
> --
> Dan Stromberg
>
> _______________________________________________
> 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/20151113/dcac0cc7/attachment-0001.html>

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

Message: 4
Date: Fri, 13 Nov 2015 21:30:25 -0500
From: Theodore Lief Gannon <tan...@gmail.com>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <beginners@haskell.org>
Subject: Re: [Haskell-beginners] Opaque (to me) compilation error
Message-ID:
        <cajopsua-idmvprrnoeg4uavep21ykwmw2bv0hs7sfmuwkzz...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Note that the analysis in my previous message is based on a trick I saw a
year ago and clearly don't properly remember or understand, because there
is no "Id" monad and the *Identity* monad is apparently not in base (though
you might still have it there, it's in both mtl and transformers).

But the bit about your type signature still stands. I'm quite certain of
that part. :)

On Fri, Nov 13, 2015 at 9:24 PM, Theodore Lief Gannon <tan...@gmail.com>
wrote:

> You're missing IO in the type declaration, which I believe means that do
> block is running in the Id monad -- by inference, Id ByteString.
>
> On Fri, Nov 13, 2015 at 8:41 PM, Dan Stromberg <strom...@gmail.com> wrote:
>
>>
>> In the following code:
>> prefix_md5 :: String -> Data.ByteString.ByteString
>> prefix_md5 filename = do
>>     let prefix_length = 1024
>>     file <- System.IO.openBinaryFile filename System.IO.ReadMode :: (IO
>> System.IO.Handle)
>>     data_read <- Data.ByteString.hGet file prefix_length :: (IO
>> Data.ByteString.ByteString)
>>     _ <- System.IO.hClose file
>>     let hasher = Crypto.Hash.MD5.init :: Crypto.Hash.MD5.Ctx
>>     let hasher2 = Crypto.Hash.MD5.update hasher data_read ::
>> Crypto.Hash.MD5.Ctx
>>     let digest = Crypto.Hash.MD5.finalize hasher2 ::
>> Data.ByteString.ByteString
>>     return digest :: (IO Data.ByteString.ByteString)
>>
>> I get the error:
>> Md5s.hs:13:5:
>>     Couldn't match type `IO Data.ByteString.ByteString'
>>                   with `Data.ByteString.ByteString'
>>     Expected type: IO System.IO.Handle
>>                    -> (System.IO.Handle -> IO Data.ByteString.ByteString)
>>                    -> Data.ByteString.ByteString
>>       Actual type: IO System.IO.Handle
>>                    -> (System.IO.Handle -> IO Data.ByteString.ByteString)
>>                    -> IO Data.ByteString.ByteString
>>     In a stmt of a 'do' block:
>>       file <- System.IO.openBinaryFile filename System.IO.ReadMode ::
>>                 IO System.IO.Handle
>>
>> How should I interpret that error to solve this kind of problem on my own
>> in the future?  I don't see where the line in question does anything with
>> ByteString's!
>>
>> How might I correct this function to eliminate the error?
>>
>> Thanks!
>>
>> --
>> Dan Stromberg
>>
>> _______________________________________________
>> 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/20151113/71afe98c/attachment-0001.html>

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

Message: 5
Date: Sat, 14 Nov 2015 10:52:37 +0700
From: Kim-Ee Yeoh <k...@atamo.com>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <beginners@haskell.org>
Subject: Re: [Haskell-beginners] Opaque (to me) compilation error
Message-ID:
        <capy+zdstdar6yyz1rfgnzmfvvzaxof3hambsus4-3om1cvs...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

On Sat, Nov 14, 2015 at 9:24 AM, Theodore Lief Gannon <tan...@gmail.com>
wrote:

> You're missing IO in the type declaration, which I believe means that do
> block is running in the Id monad -- by inference, Id ByteString.


There's no running in the Id monad. The compiler doesn't understand monads
the way we'd like it to. It's all very syntactic, namely:

1. the compiler desugars the do block into an expression
2. it typechecks the expression: no special understanding of the monad
typeclass involved
3. and if there are errors, it reports them

What we're seeing is special handling for stage 3: reporting errors in a
do-block. Sometimes it helps, sometimes it hinders. For instance, the
derivation of this signature is confusing indeed:

   IO System.IO.Handle
-> (System.IO.Handle -> IO Data.ByteString.ByteString)
-> Data.ByteString.ByteString



-- Kim-Ee
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20151114/31516e12/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 89, Issue 24
*****************************************

Reply via email to