Send Beginners mailing list submissions to beginners@haskell.org 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 beginners-requ...@haskell.org
You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than "Re: Contents of Beginners digest..." Today's Topics: 1. My Bitcoin miner (Zhi-Qiang Lei) 2. Re: Search for docs on operator '<+>'. (Allen S. Rout) 3. guards (kolli kolli) 4. Re: guards (Chadda? Fouch?) 5. Re: guards (kolli kolli) 6. Show a function? (Costello, Roger L.) 7. Re: Show a function? (Tony Morris) 8. Re: guards (Daniel Schoepe) 9. Re: guards (Brent Yorgey) ---------------------------------------------------------------------- Message: 1 Date: Thu, 10 Nov 2011 21:10:14 +0800 From: Zhi-Qiang Lei <zhiqiang....@gmail.com> Subject: [Haskell-beginners] My Bitcoin miner To: Haskell Beginer <beginners@haskell.org> Message-ID: <5c2657df-941a-4443-b586-5ed4b681b...@gmail.com> Content-Type: text/plain; charset="us-ascii" Hi, Learning Haskell, I write a Bitcoin miner for practice. Currently it's very basic(single thread, non-long-polling support). You are free and welcome to modify it. Best regards, Zhi-Qiang Lei zhiqiang....@gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://www.haskell.org/pipermail/beginners/attachments/20111110/619f10c9/attachment-0001.htm> ------------------------------ Message: 2 Date: Thu, 10 Nov 2011 15:21:49 -0500 From: "Allen S. Rout" <a...@ufl.edu> Subject: Re: [Haskell-beginners] Search for docs on operator '<+>'. To: beginners@haskell.org Message-ID: <j9hbot$b8q$1...@dough.gmane.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed On 11/09/2011 01:24 PM, Brent Yorgey wrote: > In fact, Allen, I now recall seeing you on the xmonad mailing list -- > perhaps you saw<+> in an xmonad config? In that case, indeed, it is > NOT the ArrowPlus operator, but something defined by xmonad. In the > context of xmonad,<+> is used for combining ManageHooks (actually, it > can be used to combine any two things which have a type that is an > instance of the 'Monoid' type class, but is most commonly used for > ManageHooks). Yes, indeed. The message I summarise from all of this is that <+> isn't an official piece of language, it's in a formal fringe that might be enclosed in the future, but for the moment is a local convention whose meaning is merely colloquially influenced by formal uses. I figured I'd pick up the conversation in xmonad-land when I had something approximating a concise question. Digressing, let me say 'thanks' for the variety of useful answers I've gotten from the haskell community on this acknowledgedly ignorant couple of questions. :) - Allen S. Rout ------------------------------ Message: 3 Date: Thu, 10 Nov 2011 15:37:17 -0700 From: kolli kolli <nammukoll...@gmail.com> Subject: [Haskell-beginners] guards To: beginners@haskell.org Message-ID: <cae7d9k6nhnusmdn5raz5myp6cjzbenbw-lf3d3qv32rrauw...@mail.gmail.com> Content-Type: text/plain; charset="iso-8859-1" Hi,, I am new to use ..plz bare with me.. How do we write two conditions using guards suppose if we have a if condition if t1 t2 t3 typing :: TypingContext -> Term -> Maybe Type --the typing relation typing capGamma (Var x) = contextLookup x capGamma typing capGama Tru = Just(TypeBool) typing capGama Fls = Just(TypeBool) typing capGama Zero = Just(TypeBool) typing capGama (Succ t) = typing capGama t typing capGama (Pred t) = typing capGama t typing capGama (IsZero t) = typing capGama t typing capGama (If t1 t2 t3) | typing capGama t1 == TypeBool && typing capGama t2 == x = Just(x) | otherwise = Nothing where x = typing capGama t3 its giving me error Couldn't match expected type `Maybe Type' against inferred type `Type' In the second argument of `(==)', namely `TypeBool' In the first argument of `(&&)', namely `typing capGama t1 == TypeBool' In the expression: typing capGama t1 == TypeBool && typing capGama t2 == TypeBool how can i give two conditions in a single guard... -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://www.haskell.org/pipermail/beginners/attachments/20111110/9a514ee6/attachment-0001.htm> ------------------------------ Message: 4 Date: Thu, 10 Nov 2011 23:51:14 +0100 From: Chadda? Fouch? <chaddai.fou...@gmail.com> Subject: Re: [Haskell-beginners] guards To: kolli kolli <nammukoll...@gmail.com> Cc: beginners@haskell.org Message-ID: <canfjzrzjzb7e_-mok3eb-cimf07pupiq_isvtcf8agonx-5...@mail.gmail.com> Content-Type: text/plain; charset=UTF-8 On Thu, Nov 10, 2011 at 11:37 PM, kolli kolli <nammukoll...@gmail.com> wrote: > its giving me? error > > ??? Couldn't match expected type `Maybe Type' > ?????????? against inferred type `Type' > ??? In the second argument of `(==)', namely `TypeBool' > ??? In the first argument of `(&&)', namely > ??????? `typing capGama t1 == TypeBool' > ??? In the expression: > ??????????? typing capGama t1 == TypeBool && typing capGama t2 == TypeBool > The problem is clearly not that you're using (&&) (which is the correct way to have two conditions in one guard) but that "typing capGama t1" is of type "Maybe Type" while TypeBool is of type "Type", so you can't compare them with an (==), maybe you meant to use "Just TypeBool" ? -- Jeda? ------------------------------ Message: 5 Date: Thu, 10 Nov 2011 15:55:48 -0700 From: kolli kolli <nammukoll...@gmail.com> Subject: Re: [Haskell-beginners] guards To: Chadda? Fouch? <chaddai.fou...@gmail.com> Cc: beginners@haskell.org Message-ID: <cae7d9k5s0epuct21xmt6kfs8rcxjhv2yyp6ofhlrq5_9xki...@mail.gmail.com> Content-Type: text/plain; charset="iso-8859-1" I have to feame the code saying in IF t1 t2 t3 If t1 has type x and if type of t2 == type of t3 then return type of t2 or t3 On Thu, Nov 10, 2011 at 3:51 PM, Chadda? Fouch? <chaddai.fou...@gmail.com>wrote: > On Thu, Nov 10, 2011 at 11:37 PM, kolli kolli <nammukoll...@gmail.com> > wrote: > > its giving me error > > > > Couldn't match expected type `Maybe Type' > > against inferred type `Type' > > In the second argument of `(==)', namely `TypeBool' > > In the first argument of `(&&)', namely > > `typing capGama t1 == TypeBool' > > In the expression: > > typing capGama t1 == TypeBool && typing capGama t2 == > TypeBool > > > > The problem is clearly not that you're using (&&) (which is the > correct way to have two conditions in one guard) but that "typing > capGama t1" is of type "Maybe Type" while TypeBool is of type "Type", > so you can't compare them with an (==), maybe you meant to use "Just > TypeBool" ? > > -- > Jeda? > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://www.haskell.org/pipermail/beginners/attachments/20111110/9cb800e9/attachment-0001.htm> ------------------------------ Message: 6 Date: Thu, 10 Nov 2011 23:18:17 +0000 From: "Costello, Roger L." <coste...@mitre.org> Subject: [Haskell-beginners] Show a function? To: "beginners@haskell.org" <beginners@haskell.org> Message-ID: <b5fee00b53cf054aa8439027e8fe177518182...@imcmbx03.mitre.org> Content-Type: text/plain; charset="us-ascii" Hi Folks, Consider this function: true = (\x y -> x) When I type this at WinGHCi: true I would like WinGHCi to show this string: TRUE Is there a way to "show" a function? /Roger ------------------------------ Message: 7 Date: Fri, 11 Nov 2011 09:23:20 +1000 From: Tony Morris <tonymor...@gmail.com> Subject: Re: [Haskell-beginners] Show a function? To: beginners@haskell.org Message-ID: <4ebc5ce8.5040...@gmail.com> Content-Type: text/plain; charset=ISO-8859-1 On 11/11/2011 09:18 AM, Costello, Roger L. wrote: > Hi Folks, > > Consider this function: > > true = (\x y -> x) > > When I type this at WinGHCi: > > true > > I would like WinGHCi to show this string: > > TRUE > > Is there a way to "show" a function? > > /Roger > > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://www.haskell.org/mailman/listinfo/beginners You can do it easily if you wrap your function up in a newtype: http://paste.pocoo.org/show/506051/ -- Tony Morris http://tmorris.net/ ------------------------------ Message: 8 Date: Fri, 11 Nov 2011 01:21:58 +0100 From: Daniel Schoepe <dan...@schoepe.org> Subject: Re: [Haskell-beginners] guards To: kolli kolli <nammukoll...@gmail.com>, Chadda? Fouch? <chaddai.fou...@gmail.com> Cc: beginners@haskell.org Message-ID: <877h37a4pl.fsf@gilead.invalid> Content-Type: text/plain; charset="utf-8" On Thu, 10 Nov 2011 15:55:48 -0700, kolli kolli <nammukoll...@gmail.com> wrote: > I have to feame the code saying in IF t1 t2 t3 > > If t1 has type x and if type of t2 == type of t3 then return type of t2 or > t3 As Chadda? said, the result of a call to typing has type Maybe Type while TypeBool has type Type, so you would have to compare the result with Just TypeBool, and not just TypeBool. The same applies to "where x = typing capGamma t3". Here x already has type Maybe Type, so passing it to Just would give you a value of type Maybe (Maybe Type). This can be resolved by returning x directly in this case: ... | typing capGama t1 == TypeBool && typing capGama t2 == x = x A minor stylistic comment: It's common to write `Just TypeBool' instead of `Just(TypeBool)', since a constructor is really just a (special kind of) function. Cheers, Daniel -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 835 bytes Desc: not available URL: <http://www.haskell.org/pipermail/beginners/attachments/20111111/d813f025/attachment-0001.pgp> ------------------------------ Message: 9 Date: Fri, 11 Nov 2011 00:02:56 -0500 From: Brent Yorgey <byor...@seas.upenn.edu> Subject: Re: [Haskell-beginners] guards To: beginners@haskell.org Message-ID: <20111111050256.ga12...@seas.upenn.edu> Content-Type: text/plain; charset=us-ascii On Fri, Nov 11, 2011 at 01:21:58AM +0100, Daniel Schoepe wrote: > On Thu, 10 Nov 2011 15:55:48 -0700, kolli kolli <nammukoll...@gmail.com> > wrote: > > with Just TypeBool, and not just TypeBool. An unfortunate case of significant case. ;) -Brent ------------------------------ _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners End of Beginners Digest, Vol 41, Issue 16 *****************************************