Send Beginners mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://www.haskell.org/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.  Defaulting the following constraint .... (Alan Buxton)
   2. Re:  Defaulting the following constraint .... (Benjamin Jones)
   3. Re:  Defaulting the following constraint .... (David McBride)
   4. Re:  Why html in platform? (Stephen Tetley)
   5.  scotty installation error (Ovidiu D)


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

Message: 1
Date: Mon, 30 Sep 2013 21:06:47 +0100
From: "Alan Buxton" <[email protected]>
To: <[email protected]>
Subject: [Haskell-beginners] Defaulting the following constraint ....
Message-ID: <[email protected]>
Content-Type: text/plain; charset="us-ascii"

Hi

 

I have something like this - purpose is that I need to drop redundant .0 in
a whole number - so to show 1.2345 as 1.2345 and to show 1.0 as 1

 

module Test where

 

niceShow x = if (isInt x) then show (floor x) else show x

 

isInt x = x == fromInteger (floor x)

But the hlint in my vim plugin keeps warning me that

 

test.hs|3 col 38 warning| Defaulting the following constraint(s) to type
`Integer'

||            (Integral a0) arising from a use of `floor' at
/tmp/test.hs:3:38-42

||            (Show a0) arising from a use of `show' at /tmp/test.hs:3:32-35

|| In the first argument of `show', namely `(floor x)'

|| In the expression: show (floor x)

|| In the expression: if (isInt x) then show (floor x) else show x

 

What does this mean? And what would I need to do in order to prevent this
warning?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20130930/3fef0b5a/attachment-0001.html>

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

Message: 2
Date: Mon, 30 Sep 2013 13:54:03 -0700
From: Benjamin Jones <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Defaulting the following constraint
        ....
Message-ID:
        <calfil_lu+1jw9qwcif940n4-yrfnpptj+o3qmrphmnsvkpr...@mail.gmail.com>
Content-Type: text/plain; charset="windows-1252"

On Mon, Sep 30, 2013 at 1:06 PM, Alan Buxton <[email protected]> wrote:

> Hi****
>
> ** **
>
> I have something like this ? purpose is that I need to drop redundant .0
> in a whole number ? so to show 1.2345 as 1.2345 and to show 1.0 as 1****
>
> ** **
>
> *module Test where*
>
> * *
>
> *niceShow x = if (isInt x) then show (floor x) else show x*
>
> * *
>
> *isInt x = x == fromInteger (floor x)*****
>
> **
>
> But the hlint in my vim plugin keeps warning me that****
>
> ** **
>
> test.hs|3 col 38 warning| Defaulting the following constraint(s) to type
> `Integer'****
>
> ||            (Integral a0) arising from a use of `floor' at
> /tmp/test.hs:3:38-42****
>
> ||            (Show a0) arising from a use of `show' at
> /tmp/test.hs:3:32-35****
>
> || In the first argument of `show', namely `(floor x)'****
>
> || In the expression: show (floor x)****
>
> || In the expression: if (isInt x) then show (floor x) else show x****
>
> ** **
>
> What does this mean? And what would I need to do in order to prevent this
> warning?****
>
>
It looks like you have a type mismatch in `isInt`, floor returns a type in
the typeclass Integral (this may or may not be an Integer) but fromInteger
demands its input be an Integer. Here are the type sigs:

ghci> :t floor
floor :: (Integral b, RealFrac a) => a -> b
ghci> :t fromIntegral
fromIntegral :: (Integral a, Num b) => a -> b

Changing `fromInteger` to `fromIntegeral` should fix this problem.

It will also help if you write down type signatures explicitly for your two
functions.

--
Benjamin Jones
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20130930/4a0a7858/attachment-0001.html>

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

Message: 3
Date: Mon, 30 Sep 2013 16:54:25 -0400
From: David McBride <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Defaulting the following constraint
        ....
Message-ID:
        <CAN+Tr43=R7LK3yzPgpUmf8DBEC=kin+ekboikzye5kfartr...@mail.gmail.com>
Content-Type: text/plain; charset="windows-1252"

It is because you do a floor on x, returning a where a is an Integral, but
which Integral is it?  Is it an Int or an Integer?  Well it decides to
default it to integer because that is what ghci does as it is the safe
option, but it decided to warn you about it just so you are aware.
Afterall integers are slower than ints, and you might have wanted an int.
You can silence the warning by telling it what to do:

niceShow x = if (isInt x) then show (floor x :: Int) else show x
niceShow x = if (isInt x) then show (floor x :: Integer) else show x


On Mon, Sep 30, 2013 at 4:06 PM, Alan Buxton <[email protected]> wrote:

> Hi****
>
> ** **
>
> I have something like this ? purpose is that I need to drop redundant .0
> in a whole number ? so to show 1.2345 as 1.2345 and to show 1.0 as 1****
>
> ** **
>
> *module Test where*
>
> * *
>
> *niceShow x = if (isInt x) then show (floor x) else show x*
>
> * *
>
> *isInt x = x == fromInteger (floor x)*****
>
> **
>
> But the hlint in my vim plugin keeps warning me that****
>
> ** **
>
> test.hs|3 col 38 warning| Defaulting the following constraint(s) to type
> `Integer'****
>
> ||            (Integral a0) arising from a use of `floor' at
> /tmp/test.hs:3:38-42****
>
> ||            (Show a0) arising from a use of `show' at
> /tmp/test.hs:3:32-35****
>
> || In the first argument of `show', namely `(floor x)'****
>
> || In the expression: show (floor x)****
>
> || In the expression: if (isInt x) then show (floor x) else show x****
>
> ** **
>
> What does this mean? And what would I need to do in order to prevent this
> warning?****
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20130930/2346e853/attachment-0001.html>

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

Message: 4
Date: Mon, 30 Sep 2013 21:57:45 +0100
From: Stephen Tetley <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Why html in platform?
Message-ID:
        <CAB2TPRDcnDPjaaEdcQF9O-L+2a-rR4PuqGm=t7suxzymalr...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

> Is html included for some historical reason?

Yes it was part of the extras that used to get shipped with GHC. With
release 6.12.1, the developers at GHC HQ moved out the non-core packages
into the Haskell Platform.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20130930/623c9bea/attachment-0001.html>

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

Message: 5
Date: Tue, 1 Oct 2013 02:32:34 +0300
From: Ovidiu D <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: [Haskell-beginners] scotty installation error
Message-ID:
        <CAKVsE7ufD5yaMGw3tv=mdgsjjcyrrrph_+dnghxg3e1mryi...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

I'm trying to write a small web application starting from here:
http://adit.io/posts/2013-04-15-making-a-website-with-haskell.html

Resolving dependencies...
Configuring scotty-0.2.0...
Building scotty-0.2.0...
Preprocessing library scotty-0.2.0...

Web/Scotty.hs:35:8:
    Could not find module `Control.Monad.Trans.Resource'
    It is a member of the hidden package `resourcet-0.4.8'.
    Perhaps you need to add `resourcet' to the build-depends in your .cabal
file.
    Use -v to see a list of the files searched for.
Failed to install scotty-0.2.0

My build-depends clause is the following:

  build-depends:       base ==4.5.*
                     , wai ==1.3.*
                     , warp ==1.3.*
                     , http-types ==0.7.*
                     , resourcet
                     , scotty
                     , text
                     , bytestring
                     , blaze-html
                     , persistent
                     , persistent-template
                     , persistent-sqlite
                     , persistent-postgresql
                     , heroku
                     , transformers ==0.3.0.0
                     , wai-middleware-static ==0.3.2
                     , wai-extra
                     , time
                     , monad-logger ==0.2.4

Any idea what is wrong with it?

I also tried to use the dependencies list without any versions and I
get the same error

Thanks
ovidiu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20131001/245ad524/attachment.html>

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

Subject: Digest Footer

_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners


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

End of Beginners Digest, Vol 63, Issue 42
*****************************************

Reply via email to