I would like to replace,
bodya href=#foo/a/body
with,
bodyfoo/body
using HXT. So far, the closest I've come is to parse the HTML and apply
the following stuff:
is_link :: (ArrowXml a) = a XmlTree XmlTree
is_link =
hasName a
replace_links_with_their_text :: (ArrowXml a) = a
Bartosz Milewski wrote:
Thanks, Heinrich. I looked at the examples and at the references you
provided. I understand the semantic model, so I guess I'm mostly trying to
understand the implementation.
Ok. As I mentioned, if you just want to use the library there is no need
to understand the
Hi,
You code fails because a link is not a node of kind Text, I think.
What you want is to get the text from a child node of an anchor node.
I think the following should work:
is_link :: (ArrowXml a) = a XmlTree XmlTree
is_link = hasName a
process_link :: (ArrowXml a) = a XmlTree XmlTree
(And just to be as precise as I can and avoid confusion, when I said
link I meant unnamed anchor node with an href attribute)
On 26 June 2012 10:15, Ivan Perez ivanperezdoming...@gmail.com wrote:
Hi,
You code fails because a link is not a node of kind Text, I think.
What you want is to get
I'm using StableNames to have a notion of function equality, and I'm
running into problems when using monadic functions.
Consider the code below, file Test.hs
import System.Mem.StableName
import Control.Monad.State
eq :: a - b - IO Bool
eq a b = do
pa - makeStableName a
Thanks Lorenzo, I'm cc'ing the list with your response also:
As you point out, when you do some kind of let-binding, using the where
clause, or explicit let as in:
main :: IO ()
main = do
let f1 = (successor :: Int - State Int Int)
let f2 = (successor :: Int - Maybe Int)
b2
The point I was making is that StableName might be what you want. You are
using it to check if two functions are the same by comparing their
stablehash. But from StableName documentation:
The reverse is not necessarily true: if two stable names are not equal,
then the objects they name may still
2012/6/26 Lorenzo Bolla lbo...@gmail.com
The point I was making is that StableName might be what you want. You are
using it to check if two functions are the same by comparing their
stablehash. But from StableName documentation:
The reverse is not necessarily true: if two stable names are
Michael Orlitzky wrote
I would like to replace,
bodya href=#foo/a/body
with,
bodyfoo/body
using HXT. So far, the closest I've come is to parse the HTML and apply
the following stuff:
is_link :: (ArrowXml a) = a XmlTree XmlTree
is_link =
hasName a
I think about StableName like the operator in C, that returns you the
memory address of a variable. It's not the same for many reasons, but by
analogy, if x == y then x == y, but x != y does not imply x != y.
So, values that are semantically equal, may be stored in different memory
locations and
In other words there is a difference between Identity and Equivalence. What
you have implemented with StableName is an Identity (sometimes called
reference equality), as opposed to an Equivalence (aka value
equality).
In Python, for example:
x = {1:2}
y = {1:2}
x == y
True
x is y
False
L.
thanks again for your comments, any idea on how to implement Equivalence
for functions?
2012/6/26 Lorenzo Bolla lbo...@gmail.com
In other words there is a difference between Identity and Equivalence.
What you have implemented with StableName is an Identity (sometimes
called reference
This is very tricky and it really depends on what you mean...
Formally, two functions are the same if they have the same domain and f(x)
== g(x) for each x in the domain. But this is not always
easy/feasible/efficient to implement! (See also
http://en.wikipedia.org/wiki/Rice%27s_theorem and
On 06/26/12 05:15, Ivan Perez wrote:
Hi,
You code fails because a link is not a node of kind Text, I think.
What you want is to get the text from a child node of an anchor node.
I think the following should work:
Yes, thank you. That makes sense now.
process_link :: (ArrowXml a) = a
On 06/26/12 10:39, Uwe Schmidt wrote:
processTopDown $ (deep getText mkText) `when` is_link
should do it. The deep getText will find all Text nodes, independent
of the nesting of elements in the a.../a element. If you then
write the result into a document every thing is fine.
One small
Yes I agree, so far StableNames have been a good approximation, except for
the problem I described when using monads/class constraints :-(
2012/6/26 Lorenzo Bolla lbo...@gmail.com
This is very tricky and it really depends on what you mean...
Formally, two functions are the same if they have
Hello Cafe,
Some time ago I tried to implement a network service using iteratee (or
enumerator, can't remember), but gave up in the end. More recently I
wanted to create something similar (a similar protocol), but failed
again.
So I'm looking for some example code or something similar (Google
On 26 June 2012 21:22, Nicolas Trangez nico...@incubaid.com wrote:
Might sound easy (and actually it's pretty easy in most other languages
I know, including an OCaml implementation), yet I fail to figure out how
to get this done using some enumerator-style library.
Well, it's easy in Haskell,
On Tue, 2012-06-26 at 21:32 +0200, Christopher Done wrote:
On 26 June 2012 21:22, Nicolas Trangez nico...@incubaid.com wrote:
Might sound easy (and actually it's pretty easy in most other languages
I know, including an OCaml implementation), yet I fail to figure out how
to get this done
On Tue, Jun 26, 2012 at 10:22 PM, Nicolas Trangez nico...@incubaid.com wrote:
Hello Cafe,
Some time ago I tried to implement a network service using iteratee (or
enumerator, can't remember), but gave up in the end. More recently I
wanted to create something similar (a similar protocol), but
On Tue, Jun 26, 2012 at 8:22 PM, Nicolas Trangez nico...@incubaid.com wrote:
Hello Cafe,
Some time ago I tried to implement a network service using iteratee (or
enumerator, can't remember), but gave up in the end. More recently I
wanted to create something similar (a similar protocol), but
On Tue, 2012-06-26 at 22:39 +0300, Michael Snoyman wrote:
I've run into those kinds of problems in the past as well. In general,
interleaving of data streams can be difficult with enumerator. That's
the reason I added connect-and-resume to conduit. I use the technique
in warp[1], which in fact
I see. So you're current implementation is not push, is it? The original
pull implementation in Fran also used Maybe events, but that was considered
inefficient. How is Reactive Banana better then Fran then?
--Bartosz
On Tue, Jun 26, 2012 at 1:40 AM, Heinrich Apfelmus
apfel...@quantentunnel.de
Hi,
MightyByte wrote:
Of course every line of your program that uses a Foo will change if you switch
to IO Foo instead.
But we often have to also change lines that don't use Foo at all. For
example, here is the type of binary trees of integers:
data Tree = Leaf Integer | Branch (Tree
We could debate this endlessly (as is common), but I would argue that a clean
design would make the option and alternative of multiplying explicit in its
design instead of including calls to fetch command line arguments in an ad-hoc
fashion everywhere.
The Haskell way of encoding this would
I'd also say that reading command-line flags inside a simple function like
amount is a pretty large code smell. The only case in which it isn't would
be when the codebase is so small that redesigning the Haskell to be in IO
(or switch between amountPlus and amountTimes) is negligible anyway.
On
Message: 12
Date: Wed, 27 Jun 2012 00:19:30 +0200
From: Tillmann Rendel ren...@informatik.uni-marburg.de
Subject: Re: [Haskell-cafe] Martin Odersky on What's wrong with
Monads
Cc: haskell-cafe@haskell.org
Message-ID: 4fea3572.5060...@informatik.uni-marburg.de
Content-Type:
On 27/06/2012, at 12:51 PM, John Lato wrote:
data Tree a = Leaf a | Branch (Tree a) ( Tree a)
deriving (Foldable, Show)
While I am familiar with deriving (Show),
I am not familiar with deriving (Foldable),
which looks rather useful.
On Tue, Jun 26, 2012 at 3:19 PM, Tillmann Rendel
ren...@informatik.uni-marburg.de wrote:
A function to add up all integers in a tree:
amount:: Tree - Integer
amount (Leaf x) = x
amount (Branch t1 t2) = amountt1 + amountt2
All fine so far. Now, consider the following additional
On Wed, Jun 27, 2012 at 9:15 AM, Richard O'Keefe o...@cs.otago.ac.nz wrote:
On 27/06/2012, at 12:51 PM, John Lato wrote:
data Tree a = Leaf a | Branch (Tree a) ( Tree a)
deriving (Foldable, Show)
While I am familiar with deriving (Show),
I am not familiar with deriving (Foldable),
which
On 27/06/2012, at 3:18 PM, John Lato wrote:
On Wed, Jun 27, 2012 at 9:15 AM, Richard O'Keefe o...@cs.otago.ac.nz wrote:
On 27/06/2012, at 12:51 PM, John Lato wrote:
data Tree a = Leaf a | Branch (Tree a) ( Tree a)
deriving (Foldable, Show)
While I am familiar with deriving (Show),
I
31 matches
Mail list logo