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. Re: typeOf raises Error (Brandon S. Allbery KF8NH)
2. Re: typeOf raises Error (Brent Yorgey)
3. Re: untilM and scanM (Brent Yorgey)
4. Referring to several constructors at once (Tomer Libal)
5. Re: Referring to several constructors at once (Tomer Libal)
6. Re: Referring to several constructors at once (David Morse)
7. First request for references (Alan Cameron)
8. Re: First request for references (Andrew Wagner)
----------------------------------------------------------------------
Message: 1
Date: Sun, 11 Jan 2009 05:21:24 -0500
From: "Brandon S. Allbery KF8NH" <[email protected]>
Subject: Re: [Haskell-beginners] typeOf raises Error
To: Frank Schwidom <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes
On 2009 Jan 11, at 5:27, Frank Schwidom wrote:
> "Integer", as i expected, but if i do so in code which is
> to compile, then there raises an error
Yes. Numeric literals like 5 are actually read as (fromIntegral 5);
then ghci applies defaulting to reduce it to Integer. When compiled,
you must resolve the polymorphism yourself.
--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [email protected]
system administrator [openafs,heimdal,too many hats] [email protected]
electrical and computer engineering, carnegie mellon university KF8NH
------------------------------
Message: 2
Date: Sun, 11 Jan 2009 11:22:28 -0500
From: Brent Yorgey <[email protected]>
Subject: Re: [Haskell-beginners] typeOf raises Error
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii
As Brandon explained, since 1 is polymorphic, and print is polymorphic
in its argument, the compiler doesn't know which type to choose. You
could fix it, for example, like this:
> ------------
> import Data.Typeable
>
> main=
> print (typeOf (1 :: Integer))
> ------------
You might protest, what is the point of using typeOf if you have to
actually put in the type annotation anyway? Well, this is a rather
contrived example; usually in a real program GHC would be able to
infer the type and an annotation would be unnecessary.
-Brent
------------------------------
Message: 3
Date: Sun, 11 Jan 2009 11:26:46 -0500
From: Brent Yorgey <[email protected]>
Subject: Re: [Haskell-beginners] untilM and scanM
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii
On Mon, Jan 05, 2009 at 02:16:11PM +0100, Jan Snajder wrote:
> Hi,
>
> is there a reason why there is no monadic version of "until" in the
> Haskell libraries? It would be defined as follows:
>
> untilM :: (Monad m) => (a -> Bool) -> (a -> m a) -> a -> m a
> untilM p f x | p x = return x
> | otherwise = f x >>= untilM p f
>
> The same applies to scanM, also not part of the libraries:
>
> scanM :: (Monad m) => (a -> b -> m a) -> a -> [b] -> m [a]
> scanM f q [] = return [q]
> scanM f q (x:xs) =
> do q2 <- f q x
> qs <- scanM f q2 xs
> return (q:qs)
>
> I often find myself in need for these. To me these seem idiomatic enough
> to be included in the library. But since they is not, I guess there must
> be another, more idiomatic way to do this.
There's no particular reason these aren't in the standard libraries
that I know of. I've written untilM myself once or twice. Perhaps
there are multiple slightly different ways to implement them and no
one can agree; or perhaps no one has ever proposed adding them. But
there's no more idiomatic way to do this that I know of.
-Brent
------------------------------
Message: 4
Date: Sun, 11 Jan 2009 20:47:44 +0100
From: Tomer Libal <[email protected]>
Subject: [Haskell-beginners] Referring to several constructors at once
To: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
Hello,
I am trying to define a logical calculus using one data type for the rules.
There are three types of rules and each has 0,1 or 2 assumptions (rule,
rule1 and rule2 below). I have defined all the rules as different
constructors so the difference between the types according to 0,1 or 2
assumptions is very weak. I would still like to be able to group the rules
in types according to the number of assumptions in order to use pattern
matching. Is there a simple way to do that or another way I should implement
the data type such that I can refer to the rules both according to their
number of assumptions and according to their type?
27 data Rule = Axiom {lowseq :: Sequent}
28 | WeakeningL {rule :: Rule, lowseq :: Sequent, foccur ::
FormulaOccur}
29 | WeakeningR {rule :: Rule, lowseq :: Sequent, foccur ::
FormulaOccur}
30 | ContractionL {rule :: Rule, lowseq :: Sequent, foccur ::
FormulaOccur}
31 | ContractionR {rule :: Rule, lowseq :: Sequent, foccur ::
FormulaOccur}
32 | PermutationL {rule :: Rule, lowseq :: Sequent}
33 | PermutationR {rule :: Rule, lowseq :: Sequent}
34 | Mix {rule1 :: Rule, rule2 :: Rule, lowseq :: Sequent, foccur
:: FormulaOccur}
35 | NotL {rule :: Rule, lowseq :: Sequent, foccur ::
FormulaOccur}
36 | NotR {rule :: Rule, lowseq :: Sequent, foccur ::
FormulaOccur}
37 | AndL {rule1 :: Rule, rule2 :: Rule, lowseq :: Sequent, foccur
:: FormulaOccur}
38 | AndR {rule1 :: Rule, rule2 :: Rule, lowseq :: Sequent, foccur
:: FormulaOccur}
39 deriving (Eq, Show)
Thanks,
Tomer
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://www.haskell.org/pipermail/beginners/attachments/20090111/7bee0003/attachment-0001.htm
------------------------------
Message: 5
Date: Mon, 12 Jan 2009 10:06:05 +0100
From: Tomer Libal <[email protected]>
Subject: Re: [Haskell-beginners] Referring to several constructors at
once
To: David Morse <[email protected]>
Cc: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
Thanks, I think this is just what I looked for.. I solved it at the end by
having a function to return the type and a list of rules for any rule, but
certainly your solution looks much better.
2009/1/12 David Morse <[email protected]>
> One beginner to another, what about just breaking down and using multiple
> data declarations, then packing the rules into the outer data type and the
> misc. parameters into the inner data type?:
>
> data RuleBox = Rule0 RuleZero | Rule1 RuleOne Rule | Rule2 RuleTwo Rule
> Rule
> data RuleZero = Axiom Sequent
> data RuleOne = WeakeningL Sequent FormulaOccur | WeakeningR Sequent
> FormulaOccur | ContractionL ... | Contraction R ... | PermutationL ... |
> PermutationR ... | NotL ... | NotR ...
> data RuleTwo = Mix Sequent FormulaOccur | AndL ... | AndR ...
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://www.haskell.org/pipermail/beginners/attachments/20090112/82b4d049/attachment-0001.htm
------------------------------
Message: 6
Date: Sun, 11 Jan 2009 23:15:04 -0500
From: "David Morse" <[email protected]>
Subject: Re: [Haskell-beginners] Referring to several constructors at
once
To: [email protected], "Tomer Libal" <[email protected]>
Message-ID:
<[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
One beginner to another, what about just breaking down and using multiple
data declarations, then packing the rules into the outer data type and the
misc. parameters into the inner data type?:
data RuleBox = Rule0 RuleZero | Rule1 RuleOne Rule | Rule2 RuleTwo Rule Rule
data RuleZero = Axiom Sequent
data RuleOne = WeakeningL Sequent FormulaOccur | WeakeningR Sequent
FormulaOccur | ContractionL ... | Contraction R ... | PermutationL ... |
PermutationR ... | NotL ... | NotR ...
data RuleTwo = Mix Sequent FormulaOccur | AndL ... | AndR ...
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://www.haskell.org/pipermail/beginners/attachments/20090111/9ddabd12/attachment-0001.htm
------------------------------
Message: 7
Date: Sat, 10 Jan 2009 20:03:45 -0000
From: "Alan Cameron" <[email protected]>
Subject: [Haskell-beginners] First request for references
To: <[email protected]>
Message-ID: <20d490290ec543be802976ddbe0b3...@alanxps>
Content-Type: text/plain; charset="us-ascii"
Hi,
I stumbled across Haskell while researching 'functional programming'.
I have done some initial reading and have the following questions:
1. Are there any references to real-world applications using this language?
I ask because most of the articles I have found seem to be of an extreme
academic nature. I want to be sure that my time will not be wasted delving
deeper.
2. Are there any tutorials with full code included which I can use on the
HUGS system I have installed?
I have found a few "A Gentle Introduction to Haskell 98" which assumes far
too much previous knowledge to be immediately useful to me.
Thanks for any replies.
Alan Cameron
------------------------------
Message: 8
Date: Mon, 12 Jan 2009 22:31:29 -0500
From: "Andrew Wagner" <[email protected]>
Subject: Re: [Haskell-beginners] First request for references
To: [email protected]
Cc: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
Perhaps this book would be of interest to you:
http://book.realworldhaskell.org/read/
They walk through lots of real-world examples.
On Sat, Jan 10, 2009 at 3:03 PM, Alan Cameron <[email protected]>wrote:
> Hi,
>
> I stumbled across Haskell while researching 'functional programming'.
> I have done some initial reading and have the following questions:
>
> 1. Are there any references to real-world applications using this language?
>
> I ask because most of the articles I have found seem to be of an extreme
> academic nature. I want to be sure that my time will not be wasted delving
> deeper.
>
> 2. Are there any tutorials with full code included which I can use on the
> HUGS system I have installed?
>
> I have found a few "A Gentle Introduction to Haskell 98" which assumes far
> too much previous knowledge to be immediately useful to me.
>
> Thanks for any replies.
>
> Alan Cameron
>
> _______________________________________________
> 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/20090112/9d5b6e93/attachment.htm
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 7, Issue 9
***************************************