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: debugging help (Kostiantyn Rybnikov)
2. Re: debugging help (Thomas Jakway)
3. Issue with MultiParamTypeClasses (Ovidiu Deac)
4. Re: debugging help (Henk-Jan van Tuyl)
5. foldr, Foldable and right-side folding (Raja)
6. Re: foldr, Foldable and right-side folding (Daniel Bergey)
----------------------------------------------------------------------
Message: 1
Date: Sat, 5 Dec 2015 17:48:27 +0200
From: Kostiantyn Rybnikov <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] debugging help
Message-ID:
<CAAbahfQpTwXoCM9GHTVMuBb2OPbbSMXa1urCE=jam+mhneg...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Not sure about windows, but for Linux ? you just do `stack build
--executable-profiling` (for cabal it's `cabal
--enable-executable-profiling`) to build with profiling.
Also, I want to recommend a package called formatting
http://hackage.haskell.org/package/formatting , which is a bit more
type-safe way to format strings:
format ("Person's name is " % text % ", age is " % hex) "Dave" 54
There are short-named formatters available, and if you omit spaces it would
look almost as dense as printf.
Cheers.
On Sat, Dec 5, 2015 at 2:50 AM, Dennis Raddle <[email protected]>
wrote:
> I'm getting an error, printf not having enough arguments. I need to find
> where this is happening, and I understand there are ways of getting a stack
> trace, but apparently I need to compile for profiling. That means I need to
> compile my one library dependency (Text.XML.Light) for profiling, I
> believe. How do I do this? I'm on Windows and have only installed libraries
> in the past with cabal.
>
> D
>
>
> _______________________________________________
> 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/20151205/7f7aeac0/attachment-0001.html>
------------------------------
Message: 2
Date: Sat, 5 Dec 2015 12:11:57 -0500
From: Thomas Jakway <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] debugging help
Message-ID: <[email protected]>
Content-Type: text/plain; charset="windows-1252"; Format="flowed"
I wouldn't approach this from that perspective. If it's just a small
codebase you might want to just grep -R "printf" . and look through each
statement. To be honest I've never really used ghci for debugging (I'm
definitely a beginner) but getting a stack trace seems like overkill and
I'd be willing to bet ghci would be more productive anyway. If you
really want to though the flag is -prof. To compile the library with it
you could edit the .cabal file and add it under ghc-options.
or cabal build --ghc-options="-prof" would probably also work.
(if I'm wrong about any of the above I'd really appreciate it if someone
more experienced than me would correct me so I don't make the same
mistakes!)
On 12/4/15 7:50 PM, Dennis Raddle wrote:
> I'm getting an error, printf not having enough arguments. I need to
> find where this is happening, and I understand there are ways of
> getting a stack trace, but apparently I need to compile for profiling.
> That means I need to compile my one library dependency
> (Text.XML.Light) for profiling, I believe. How do I do this? I'm on
> Windows and have only installed libraries in the past with cabal.
>
> D
>
>
>
> _______________________________________________
> 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/20151205/9e6abc66/attachment-0001.html>
------------------------------
Message: 3
Date: Sat, 5 Dec 2015 19:35:42 +0200
From: Ovidiu Deac <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: [Haskell-beginners] Issue with MultiParamTypeClasses
Message-ID:
<CAKVsE7unR+jM7FUAC25F=8cugn2jewev7+dec8uqt5ns+un...@mail.gmail.com>
Content-Type: text/plain; charset=UTF-8
I have the following code:
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
class Graph g a where
vertices :: g a -> [a]
edges :: g a-> [(a, a)]
type AdjList a = [(a,[a])]
instance Graph AdjList Int where
vertices g = map fst g
edges g = concatMap listEdges g
where listEdges (startV, edges) = map (\endV -> (startV, endV)) edges
but the compiler complains:
"""Type synonym ???AdjList??? should have 1 argument, but has been given none
In the instance declaration for ???Graph AdjList Int??? """
How can I fix this error?
Thanks!
------------------------------
Message: 4
Date: Sun, 06 Dec 2015 00:31:07 +0100
From: "Henk-Jan van Tuyl" <[email protected]>
To: "Haskell Beginners" <[email protected]>, "Dennis Raddle"
<[email protected]>
Subject: Re: [Haskell-beginners] debugging help
Message-ID: <op.x86199hipz0j5l@alquantor>
Content-Type: text/plain; charset=iso-8859-15; format=flowed;
delsp=yes
On Sat, 05 Dec 2015 01:50:22 +0100, Dennis Raddle
<[email protected]> wrote:
> I'm getting an error, printf not having enough arguments. I need to find
> where this is happening, and I understand there are ways of getting a
> stack
> trace, but apparently I need to compile for profiling. That means I need
> to
> compile my one library dependency (Text.XML.Light) for profiling, I
> believe. How do I do this? I'm on Windows and have only installed
> libraries
> in the past with cabal.
Try the GHCi debugger:
https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/ghci-debugger.html
Regards,
Henk-Jan van Tuyl
--
Folding@home
What if you could share your unused computer power to help find a cure? In
just 5 minutes you can join the world's biggest networked computer and get
us closer sooner. Watch the video.
http://folding.stanford.edu/
http://Van.Tuyl.eu/
http://members.chello.nl/hjgtuyl/tourdemonad.html
Haskell programming
--
------------------------------
Message: 5
Date: Sat, 5 Dec 2015 19:20:58 -0500
From: Raja <[email protected]>
To: [email protected]
Subject: [Haskell-beginners] foldr, Foldable and right-side folding
Message-ID:
<capzi6dmxfxmwfvzwcwskwq1bhjt7y8gqudg2ldmoy3lpfsm...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
foldr is supposed to start folding from the right side (as the name
suggests).
and this is why it is synonymous to "list construction" as I'm told
for e.g:
> foldr (:) [ ] [1,2,3,4,5]
[1,2,3,4,5]
In the same spirit I'm trying to construct a Foldable instance of my own
type:
data Li a = Nil | Cons a (Li a)
deriving (Show)
instance Foldable Li where
foldr f b Nil = b
foldr f b (Cons a y) = foldr f (f a b) y
So I'm trying out foldr for my type:
> foldr Cons Nil (Cons 1 (Cons 2 Nil))
Cons 2 (Cons 1 Nil)
This shows my foldr implementation i'm not folding from right side,
but how can I possibly do that - the data could have been an infinite
stream.
It feels like I will never be able to truly write a foldr implementation
with "right" folding mechanism.
Any thoughts?
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20151205/3cd48dda/attachment-0001.html>
------------------------------
Message: 6
Date: Sat, 05 Dec 2015 22:24:03 -0500
From: Daniel Bergey <[email protected]>
To: Raja <[email protected]>, [email protected]
Subject: Re: [Haskell-beginners] foldr, Foldable and right-side
folding
Message-ID:
<87d1uk9s4s.fsf@chladni.i-did-not-set--mail-host-address--so-tickle-me>
Content-Type: text/plain
On 2015-12-05 at 19:20, Raja <[email protected]> wrote:
> foldr is supposed to start folding from the right side (as the name
> suggests).
> and this is why it is synonymous to "list construction" as I'm told
>
> for e.g:
>> foldr (:) [ ] [1,2,3,4,5]
> [1,2,3,4,5]
>
> In the same spirit I'm trying to construct a Foldable instance of my own
> type:
>
> data Li a = Nil | Cons a (Li a)
> deriving (Show)
>
> instance Foldable Li where
> foldr f b Nil = b
> foldr f b (Cons a y) = foldr f (f a b) y
>
> So I'm trying out foldr for my type:
>> foldr Cons Nil (Cons 1 (Cons 2 Nil))
> Cons 2 (Cons 1 Nil)
>
> This shows my foldr implementation i'm not folding from right side,
> but how can I possibly do that - the data could have been an infinite
> stream.
A right fold on an infinite stream can terminate if the function f
sometimes discards it's second argument. For example, takeWhile can be
implemented this way.
You are right that `foldr Cons Nil` or `foldr (:) []` will not terminate
on an infinite list.
On the bright side, you 've written a perfectly good left fold, even
though it doesn't have quite the signature Haskell gives foldl.
bergey
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 90, Issue 9
****************************************