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.  cabal binary packages (harry)
   2.  Compiler can't deduce Bool as instance of        ToField
      (Bryan Vicknair)
   3. Re:  print [] (David Virebayre)
   4. Re:  print [] (Lukas Lehner)
   5. Re:  Sorting Bank Accounts problem in Haskell (David Virebayre)
   6. Re:  print [] (David Virebayre)


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

Message: 1
Date: Tue, 13 Aug 2013 18:55:22 +0000 (UTC)
From: harry <[email protected]>
To: [email protected]
Subject: [Haskell-beginners] cabal binary packages
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii

I need to build some software on a server, but it doesn't have enough spare
memory for compiling all the dependencies. I would like to create a binary
distribution of e.g. snap including all of its dependencies (other than
those which come with ghc), so that the server can just install them. I
found
http://www.haskell.org/cabal/users-guide/installing-packages.html#creating-a-binary-package,
but this seems to have two deficiencies - the destination prefix needs to be
know in advance (which might be OK if it can be a relative path), and it has
to be done individually for each package.




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

Message: 2
Date: Wed, 14 Aug 2013 02:25:02 -0700
From: Bryan Vicknair <[email protected]>
To: [email protected]
Subject: [Haskell-beginners] Compiler can't deduce Bool as instance of
        ToField
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii

postgresql-simple declares Bool as an instance of the ToField class.  The
compiler can't deduce that given this simple code however:

  import Database.PostgreSQL.Simple.ToField (ToField(..))
  
  foo :: (ToField a) => a
  foo = True
  
  
It fails with this error:

  Db.hs:64:7:
      Could not deduce (a ~ Bool)
      from the context (ToField a)
        bound by the type signature for foo :: ToField a => a
        at Db.hs:63:8-23
        `a' is a rigid type variable bound by
            the type signature for foo :: ToField a => a at Db.hs:63:8
      In the expression: True
      In an equation for `foo': foo = True
  Failed, modules loaded: none.

What am I missing?



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

Message: 3
Date: Wed, 14 Aug 2013 12:08:39 +0200
From: David Virebayre <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] print []
Message-ID:
        <cam_wfvsga+vn65twp0ov6ocfhluhc9garketuqjx-hynixu...@mail.gmail.com>
Content-Type: text/plain; charset=UTF-8

2013/8/13 Lukas Lehner <[email protected]>:
> Good to know extension. And without it?

Someone correct me if I'm wrong, here's how I understand it:

To execute print [], ghc has to find which instance of Show to call.
How could it find an instance without knowing the type ?
[] could be a list of anything, and while in theory we know that in
all cases it should print "[]", in practice ghc can't call that code
if it doesn't know the type of the list.

David.



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

Message: 4
Date: Wed, 14 Aug 2013 12:15:11 +0200
From: Lukas Lehner <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] print []
Message-ID:
        <CAL+wLLimU-NNSbb_KKwUeCef7iB0ds0ujycYzu1nL=5cfm-...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

That I understand. My question is that I have to enforce the type that
specific way (don't want to use ExtendedDefaultRules) or is there some more
generic way?


On Wed, Aug 14, 2013 at 12:08 PM, David Virebayre <
[email protected]> wrote:

> 2013/8/13 Lukas Lehner <[email protected]>:
> > Good to know extension. And without it?
>
> Someone correct me if I'm wrong, here's how I understand it:
>
> To execute print [], ghc has to find which instance of Show to call.
> How could it find an instance without knowing the type ?
> [] could be a list of anything, and while in theory we know that in
> all cases it should print "[]", in practice ghc can't call that code
> if it doesn't know the type of the list.
>
> David.
>
> _______________________________________________
> 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/20130814/87b65be6/attachment-0001.html>

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

Message: 5
Date: Wed, 14 Aug 2013 12:17:48 +0200
From: David Virebayre <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Sorting Bank Accounts problem in
        Haskell
Message-ID:
        <cam_wfvva-dkx4s4stfzcy8-1samhpvaetuqt8rfhmgi3a_x...@mail.gmail.com>
Content-Type: text/plain; charset=UTF-8

You should probably start by switching strings to Data.Text.

David.

2013/8/13 Nadav Chernin <[email protected]>:
> Hi all,
> I learn Haskell and i try to solve questions from SPOJ.
>
> Currently, i try to solve problem Sorting Bank Accounts
>
> Here is my code:
>
> import qualified Data.Map as M
>
> extractTest []=[]
> extractTest (x:xs)=(take n xs):(extractTest (drop (n+1) xs)) where
> n=read x
>
> emp=M.empty
>
> collect m []=m
> collect m (x:xs)
> |M.member x m =collect (M.insert x (amount+1) m) xs
> |otherwise=collect (M.insert x 1 m) xs
> where
> Just amount=M.lookup x m
>
> getList m=map (\(x,k)->x++" "++(show k)) (M.toList m)
> f x=unlines$(getList (collect emp x))++[""]
> main=getLine>>=(\x->interact$unlines.map f.take (read x).extractTest.lines)
>
> The problem is that i can't finish it during 7 sec.
> So i want to know is there more quick solution/method for this problem.
> Thanks, Nadav
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>



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

Message: 6
Date: Wed, 14 Aug 2013 12:24:29 +0200
From: David Virebayre <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] print []
Message-ID:
        <CAM_wFVsSuh4o6+ZzdEk9P1mNDBQGZ+TqdRb=vwavsazjhh-...@mail.gmail.com>
Content-Type: text/plain; charset=UTF-8

2013/8/14 Lukas Lehner <[email protected]>:
> That I understand. My question is that I have to enforce the type that
> specific way (don't want to use ExtendedDefaultRules) or is there some more
> generic way?

Ah, sorry, I don't know of a more generic way. But I'm not experienced
enough to be sure. My experience is than in real world code, most of
the time, the way you use the values gives enough info for ghc to
infer a type.

Sometimes, you can avoid adding type information by using aTypeOf from
the Prelude.

David.



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

Subject: Digest Footer

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


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

End of Beginners Digest, Vol 62, Issue 15
*****************************************

Reply via email to