Thank you for these excellent explanations.
Best regards,
Jerz
--
View this message in context:
http://haskell.1045720.n5.nabble.com/a-simple-question-about-types-tp3269519p3272344.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com
Daniel Fischer daniel.is.fisc...@web.de writes:
On Wednesday 17 November 2010 19:09:16, Jerzy M wrote:
Hallo,
let me take this simple function: (2*).
If I check its type
:t (2*)
I'll obtain
(2*) :: (Num a) = a - a
But now it suffices to write
g = (2*)
and check
:t g
to obtain
g
Hallo,
let me take this simple function: (2*).
If I check its type
:t (2*)
I'll obtain
(2*) :: (Num a) = a - a
But now it suffices to write
g = (2*)
and check
:t g
to obtain
g :: Integer - Integer
One more combination, now I write
h x = (2*) x
and check once more
:t h
to get
h :: (Num a) = a - a
On Nov 17, 2010, at 10:09 AM, Jerzy M wrote:
So my question is: why (in this second example) Integer is inferred?
What makes a difference?
I think there are two things going on. First, the monomorphism
restriction is causing the types to be different. I'm not sure why
Integer -
On Wednesday 17 November 2010 19:09:16, Jerzy M wrote:
Hallo,
let me take this simple function: (2*).
If I check its type
:t (2*)
I'll obtain
(2*) :: (Num a) = a - a
But now it suffices to write
g = (2*)
and check
:t g
to obtain
g :: Integer - Integer
One more combination, now I
Now of course, the followup question is what the heck is a
monomorphism restriction and why would I want it?
Here is a simple example:
expensiveComputation :: Num a = a - a
expensiveComputation x = ... something that takes a long time to compute ...
ghci :t (expensiveComputation 2 *)
On Wednesday 17 November 2010 20:19:17, Ryan Ingram wrote:
Now of course, the followup question is what the heck is a
monomorphism restriction and why would I want it?
Here is a simple example:
snip
But if you give g the more general type signature, the
expensiveComputation has to get run
On 9/24/10 5:35 AM, Axel Benz wrote:
Can anybody explain why this happens and how I can compose f and g?
Hint: It works fine if f is defined as an unary function.
As already mentioned: (g . f) x y = (\z- g (f z)) x y = g (f x) y
In order to get it to work you need to say that you want to
Hello,
this is maybe a simple question:
cbinary :: a - b - (a - b - b) - (b - c) - c
-- Version 1 works:
cbinary x y f g = g (f x y)
-- Version 2 should be exactly the same according
-- to my understanding of the . operator definition,
-- but fails with:
-- Occurs check
(g . f) x y = (\z - g (f z)) x y = g (f x) y, and you need g (f x y), which
is definitely not the same thing.
24.09.2010 13:35, Axel Benz пишет:
Hello,
this is maybe a simple question:
cbinary :: a - b - (a - b - b) - (b - c) - c
-- Version 1 works:
cbinary x y f g = g (f x y
Hello,
I'm trying to learn how to use HaXml, but I'm having trouble getting off
the ground. I can see from the documentation how to process XML using
the combinators and processXmlWith, but processXmlWith seems to hide
the actual process of reading and parsing the XML. Suppose that
processXmlWith
I have a hoogle question. While I was reading the HXT discussion
(below), I tried to search runX and readString in Hoogle (since I
am new to HXT and Arrows). But neither search yielded any result and I
had to use google to find the Haskell docs.
So I am wondering what is the scope of Hoogle that
Hi
I have a hoogle question. While I was reading the HXT discussion
(below), I tried to search runX and readString in Hoogle (since I
am new to HXT and Arrows). But neither search yielded any result and I
had to use google to find the Haskell docs.
So I am wondering what is the scope of
Hi Fernand,
Everything works fine except for the fact that all the nodes « this
/this »
(that is, a space (an XML text node whose contents are a single space
character)
within a this element node) get transformed to a « this/ » element
I can't really reproduce this:
A simple ghci session
I can't really reproduce this:
A simple ghci session gives the following:
---
[EMAIL PROTECTED]:~/haskell/hxt/curr/examples/arrows/HelloWorld ghci
HelloWorld.hs
GHCi, version 6.8.1: http://www.haskell.org/ghc/ :? for help
Loading package base ... linking
Hi Miguel,
Hmmm, with 'readString ... this /this' everything works fine,
but with 'readString ... itemsthis /this/items' it doesn't.
Seems to be a bug in HXT.
I don't see the bug:
--
*Main runX $ ( readString [(a_validate,v_0)] itemsthis /this/items
Prelude Text.XML.HXT.Arrow runX $ ( readString [(a_validate,v_0)]
xy /y/x setTraceLevel 4 traceDoc doc after reading
s
etTraceLevel 0 writeDocumentToString [(a_indent, v_1)])
-- (1) doc after reading
x
y/
/x
content of: xy /y/x
=
---XTag /
| source=\xy
Hi Miguel,
Try xy /y/x and a_indent writing option.
yes, with the indent option set, whitespace
becomes insignificant and will change during
formating, and so the contents
of the inner element reduces to empty
Turn of the indentation and you get the
result you want.
Cheers,
Uwe
--
Web:
Hi,
I'm using HXT (7.4) with GHC to make some XML transformations (BTW,
congratulations to the maintainers of that package for their impressive
work).
Everything works fine except for the fact that all the nodes « this
/this »
(that is, a space (an XML text node whose contents are a single
Miguel Mitrofanov a écrit :
Seems rather strange for me, I've just installed HXT and got this:
Prelude Text.XML.HXT.Arrow runX $ readString [(a_validate,0)] this /this
writeDocumentToString []
[?xml version=\1.0\ encoding=\UTF-8\?\nthis /this]
Everything works fine except for the fact
Hmmm, with 'readString ... this /this' everything works fine,
but with 'readString ... itemsthis /this/items' it doesn't.
Seems to be a bug in HXT.
But if I try the same with my XML file, my empty nodes are
folded. I suppose this comes from the Ctrl-M at the end of the
lines.
See the
Taillefer, Troy (EXP) wrote:
Hi there
1. First of all never forget your base case for exiting your recursion
2. you need to break up the problem like so
import Char
-- get the first word
word :: String - String
word [] = []
word ( x : x1 : xs )
| isSpace x = []
| isSpace x1 =
with the variable value updated.
setVal :: Store - (Variable, Data) - Store
--
View this message in context:
http://www.nabble.com/pls-fast-help-me-with-this-simple-question-t1345292.html#a3598605
Sent from the Haskell - Haskell-Cafe forum at Nabble.com.
___
Haskell
On 3/26/06, iliali16 [EMAIL PROTECTED] wrote:
type Data = Integer
type Variable = String
type Store = [(Variable, Data)]
Store = [(,0)]
emptystore :: Store
emptystore = [(,0)]
getVal :: Store - Variable - Data
thats my code i just have to continue and get the value of a variable from
What is $ function good for?
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
On Saturday 02 April 2005 22:29, Peter Hercek wrote:
What is $ function good for?
Mostly for avoiding parentheses. $ is right associative and has lowest
precedence, whereas normal application is left associative and binds most
tightly:
f $ g $ h x === f ( g ( h x ) )
There are more
At 10:56 PM +0200 4/2/05, Benjamin Franksen wrote:
On Saturday 02 April 2005 22:29, Peter Hercek wrote:
What is $ function good for?
Mostly for avoiding parentheses. $ is right associative and has lowest
precedence, whereas normal application is left associative and binds most
tightly:
f $ g $
On Tue, 2 Nov 2004, Marc Charpentier wrote:
Doing some calculations in ghci, I encountered a difficulty which I
cannot resolve.
Here's a distilled version, prepared for the command line:
let i = 2 in (-1)^i/(2^(10*i)) * (-2^5/(4*i+1))
Monomorphism was the short answer, the long
On Wed, 3 Nov 2004, Marc Charpentier wrote:
Thank you all for the friendly and helpful explanations - and for your
patience.
The solution to my problem is finally
f :: Double - Double
f i = (-1)**i/(2**(10*i)) * (-2^5/(4*i+1)-1/(4*i+3)+2^8/(10*i+1)
On Tue, Nov 02, 2004 at 09:53:28PM +0100, Marc Charpentier wrote:
Good evening,
Doing some calculations in ghci, I encountered a difficulty which I
cannot resolve.
Here's a distilled version, prepared for the command line:
let i = 2 in (-1)^i/(2^(10*i)) * (-2^5/(4*i+1))
Hi,
When I run my main function I get an error:
The prompt does not wait for user input and thus my parser
fails with an empty head.
Is there a switch to not echo to the console? Is this
the problem? It happens in both Hugs and GHC
main :: IO ()main = do
putStr "sentence?
" input -
On style, yes. A concrete example of what I asked before.
The following doesn't type check for obvious reasons.
In your opinion what is the most elegant way to fix it?
Like I said, I'm starting to feel like defining my own operators is the way to
go. On the other hand, this kind of situation
Hi, I'm sorry to bother everyone again with this simple append' stuff
-- below is my revised append' function
1) append' :: [[a]] - a - [[a]]
2) append' [] y = [[y]]
3) append' (x:xs) y =
4) case xs of [] - foldr (:) [y] x
5)(z:zs) - (init (x:xs)) ++ [(last xs)++[y]]
-- to
On Fri, 17 May 2002, Jerry wrote:
Hi, I'm sorry to bother everyone again with this simple append' stuff
-- now this is something I _really_ don't understand:
-- x is of type [a], [y] is of type [a], and isn't foldr (:) [a] [a]
-- perfectly valid?!
:type foldr
forall a b. (a - b - b) - b -
Hi, enlightenment much appreciated for my newbie question --
to achieve:
append' [ [1, 2], [3, 4], [5] ] 6 - [ [1, 2], [3, 4], [5, 6] ]
append' [ ['1', '2'], ['3'] ] '4' - [ ['1', '2'], ['3', '4'] ]
append' [ [True], [True] ] False - [ [True], [True, False] ]
so I (naively) write:
18) append'
Hi,
JiJie 20) append' x:xs y = [(init x:xs)] ++ [(tail xs)++[y]]
function application (blank) binds stronger than :,
thus you should write
append' (x:xs) y = ...
Cheers
--
Christoph
___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
* Ch. A. Herrmann [EMAIL PROTECTED] [020516 21:38]:
Hi,
JiJie 20) append' x:xs y = [(init x:xs)] ++ [(tail xs)++[y]]
function application (blank) binds stronger than :,
thus you should write
append' (x:xs) y = ...
-- so I added the parenthesis:
18) append' :: [[a]] - a -
To make it short:
Main let append' xs y = init xs ++ [last xs ++ [y]]
This works for the three given examples but maybe incorrect
for the task you have in mind, e.g., if xs is empty.
Main append' [ [1, 2], [3, 4], [5] ] 6
[[1,2],[3,4],[5,6]]
Main append' [ ['1', '2'], ['3'] ] '4'
[12,34]
Main
Hi,
I am trying to do some exercies in my Haskell book. I couldn't get my
program to work correctly.
type Database2 = [ (Person,[ Book ]) ]
exampleBase2 :: Database2
exampleBase2 = [ (Alice, [ Tintin, Astrix ] ),
(Anna, [ Little Woman ] ),
(Rory, [ Tintin ] )
]
books2 :: Database2 -
Cagdas Ozgenc wrote:
books2 :: Database2 - Person - [Book]
books2 db person = head [ snd tuple | tuple - db, fst tuple == person ]
borrowers2 :: Database2 - Book - [Person]
borrowers2 db book = [ person | (person, books) - db, book - books ]
You can't pattern match against a variable
Suppose I define a new type class MyClass with some methods
class MyClass a where
-- Basic methods
m :: Some type including a
...
-- Derived Methods
dm :: Some type including a
dm = Definition of dm that depends on m
...
However, I could
Is it better to type the derived methods inside the class
definition or out? Are there any efficiency penalties
in any of the styles?
In Haskell98 Prelude there is a mixture of both styles, for example,
() is defined inside the Monad class, but (=) is left out.
Good question. The
| Jin Yang [EMAIL PROTECTED] writes ...
|
| I wrote a translator in Haskell and it was compiled OK using an earlier ghc
| version. Now the ghc at my department (Dept of Computing , Imperial) was
| upgrated to ghc0.26 and all my code got a compiling error:
|ld: Undefined symbol
|
43 matches
Mail list logo