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. Re: Category question (Brent Yorgey) 2. Re: Category question (Manfred Lotz) 3. Re: problems with wxHaskell installation (Miguel Negrao) 4. Re: Category question (Jay Sulzberger) 5. Re: problems with wxHaskell installation (Heinrich Apfelmus) 6. How to solve this using State Monad? (kak dod) ---------------------------------------------------------------------- Message: 1 Date: Mon, 28 May 2012 12:43:33 -0400 From: Brent Yorgey <byor...@seas.upenn.edu> Subject: Re: [Haskell-beginners] Category question To: beginners@haskell.org Message-ID: <20120528164333.ga5...@seas.upenn.edu> Content-Type: text/plain; charset=us-ascii On Mon, May 28, 2012 at 04:14:40PM +0200, Manfred Lotz wrote: > > For me id: A -> A could be defined by: A morphism id: A -> A is > called identity morphism iff for all x of A we have id(x) = x. This is not actually a valid definition; the notation id(x) = x does not make sense. It seems you are assuming that morphisms represent some sort of function, but that is only true in certain special categories. > My point is that in the books about category theory those two statements > are stated as axioms, and id is (in many books) just self understood or > defined as I have defined it above. > > If in a book about category the author would say that for each object A > there must exist a morphism id: A -> A (called identity morphism) which > is defined by idB . f = f and f . idA = f then this would be clearer > (and better, IMHO). This is exactly what category theory books do (or should) say. Do you have a particular example of a book which does not state things in this way? Note that there is no particular difference between calling these equations "axioms" or a "definition". That is, "there is an 'identity morphism' satisfying the following axioms..." and "there is an 'identity morphism' defined by..." are just two different ways of saying the exact same thing. -Brent ------------------------------ Message: 2 Date: Mon, 28 May 2012 18:50:34 +0200 From: Manfred Lotz <manfred.l...@arcor.de> Subject: Re: [Haskell-beginners] Category question To: beginners@haskell.org Message-ID: <20120528185034.51ed2...@arcor.com> Content-Type: text/plain; charset=US-ASCII On Mon, 28 May 2012 10:57:11 -0400 Brent Yorgey <byor...@seas.upenn.edu> wrote: > On Mon, May 28, 2012 at 04:14:40PM +0200, Manfred Lotz wrote: > > > > For me id: A -> A could be defined by: A morphism id: A -> A is > > called identity morphism iff for all x of A we have id(x) = x. > > This is not actually a valid definition; the notation id(x) = x does > not make sense. It seems you are assuming that morphisms represent > some sort of function, but that is only true in certain special > categories. > Ok, it is a valid definition only in a certain context. In the far wider context of category theory this indeed makes no sense. > > My point is that in the books about category theory those two > > statements are stated as axioms, and id is (in many books) just > > self understood or defined as I have defined it above. > > > > If in a book about category the author would say that for each > > object A there must exist a morphism id: A -> A (called identity > > morphism) which is defined by idB . f = f and f . idA = f then this > > would be clearer (and better, IMHO). > > This is exactly what category theory books do (or should) say. Do you > have a particular example of a book which does not state things in > this way? > In 'Conceptual Mathematics' by F. William Lawvere, Stephen H. Schanuel they define an identity map with fa = a for each a in A. Then on page 17 they define category and say ... Identity Maps: (one per object) 1A: A -> A ... Rules for a category 1. The identity laws: where they say g . 1A = g and 1B . f = f 2. associatlve laws ... It seems that this definition of a category is not as general as it could be. Here 1. is something which follows easily from the definition of an identity map. I guess that this made me think of idA as idA(x) = x for each x of A. Later when I saw other (more general) definitions I did not read carefully to realize the difference. Thanks a lot for making this clear to me. -- Manfred ------------------------------ Message: 3 Date: Mon, 28 May 2012 18:31:08 +0100 From: Miguel Negrao <miguel.negrao-li...@friendlyvirus.org> Subject: Re: [Haskell-beginners] problems with wxHaskell installation To: beginners@haskell.org Message-ID: <31f41061-3886-4356-a3d1-6ed3499a1...@friendlyvirus.org> Content-Type: text/plain; charset=windows-1252 Hi Heinrich, Thanks for helping out. Seems I?m really unlucky with cabal and wxHaskell... A 28/05/2012, ?s 12:57, Heinrich Apfelmus escreveu: > Miguel Negrao wrote: >> I had wxHaskell working but since I installed the gtk2hs, which updated some >> packages I?m having some trouble. I?ve installed wxWidgets and wxHaskell >> again following the instructions in it?s webpage. When I compile a simple >> wxHaskell program* I get this error: >> dyld: Symbol not found: _wxTheAssertHandler >> Referenced from: >> /Users/miguelnegrao/Library/Haskell/ghc-7.0.4/lib/wxc-0.90.0.3/lib/libwxc.dylib >> Expected in: /usr/local/lib/libwx_baseu-2.9.3.0.0.dylib >> in >> /Users/miguelnegrao/Library/Haskell/ghc-7.0.4/lib/wxc-0.90.0.3/lib/libwxc.dylib >> Trace/BPT trap: 5 >> How can I fix this ? >> thank you, >> Miguel Negr?o >> I?m on OSX 10.7.3 haskell platform with ghc 7.0.4 >> brew info wxmac >> wxmac 2.8.12 >> http://www.wxwidgets.org >> /usr/local/Cellar/wxmac/2.9.3.1 (764 files, 26M) * >> Installed with: --devel >> https://github.com/mxcl/homebrew/commits/master/Library/Formula/wxmac.rb >> cabal info wx >> * wx (library) >> Synopsis: wxHaskell >> Versions available: 0.11.1.0, 0.11.1.2, 0.12.1.4, 0.12.1.5, 0.12.1.6, >> 0.13.2, 0.13.2.1, 0.90, 0.90.0.1 (and 10 others) >> Versions installed: 0.13.1, 0.90 > > I don't really know what's going on, but there seem to be two potential > issues: > > * Your wx package has version 0.90 while your wxc package has version > 0.90.0.3. I recommend to use the latest patch level releases of all three: > wx, wxcore and wxc. When I try to install wx after updating cabal it is failing on version 0.90.0.1: miguelnegrao@Mac-Miguel:~$ cabal install wx Resolving dependencies... Configuring wx-0.90.0.1... Preprocessing library wx-0.90.0.1... Building wx-0.90.0.1... [ 1 of 16] Compiling Graphics.UI.WX.Types ( src/Graphics/UI/WX/Types.hs, dist/build/Graphics/UI/WX/Types.o ) [ 2 of 16] Compiling Graphics.UI.WX.Attributes ( src/Graphics/UI/WX/Attributes.hs, dist/build/Graphics/UI/WX/Attributes.o ) [ 3 of 16] Compiling Graphics.UI.WX.Layout ( src/Graphics/UI/WX/Layout.hs, dist/build/Graphics/UI/WX/Layout.o ) [ 4 of 16] Compiling Graphics.UI.WX.Classes ( src/Graphics/UI/WX/Classes.hs, dist/build/Graphics/UI/WX/Classes.o ) [ 5 of 16] Compiling Graphics.UI.WX.Media ( src/Graphics/UI/WX/Media.hs, dist/build/Graphics/UI/WX/Media.o ) [ 6 of 16] Compiling Graphics.UI.WX.Events ( src/Graphics/UI/WX/Events.hs, dist/build/Graphics/UI/WX/Events.o ) [ 7 of 16] Compiling Graphics.UI.WX.Window ( src/Graphics/UI/WX/Window.hs, dist/build/Graphics/UI/WX/Window.o ) src/Graphics/UI/WX/Window.hs:134:52: Not in scope: `textCtrlChangeValue' cabal: Error: some packages failed to install: wx-0.90.0.1 failed during the building phase. The exception was: ExitFailure 1 Does this mean that the package that was pushed to cabal has an actual error ? How do I "use the latest patch level releases? of the packages ? > > * Your wxWidgets (wxmax) version is reported both as 2.8.12 and 2.9.3.1 right. But that is because the current stable version is 2.8.12 and to use the latest version in homebrew I have to use the switch --devel which will install 2.9.3.1. I followed the instructions here :http://www.haskell.org/haskellwiki/WxHaskell/MacOS_X best, Miguel ------------------------------ Message: 4 Date: Mon, 28 May 2012 13:43:33 -0400 (EDT) From: Jay Sulzberger <j...@panix.com> Subject: Re: [Haskell-beginners] Category question To: beginners@haskell.org Message-ID: <pine.neb.4.64.1205281310020.24...@panix3.panix.com> Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed On Mon, 28 May 2012, Manfred Lotz <manfred.l...@arcor.de> wrote: > On Mon, 28 May 2012 10:57:11 -0400 > Brent Yorgey <byor...@seas.upenn.edu> wrote: > >> On Mon, May 28, 2012 at 04:14:40PM +0200, Manfred Lotz wrote: >>> >>> For me id: A -> A could be defined by: A morphism id: A -> A is >>> called identity morphism iff for all x of A we have id(x) = x. >> >> This is not actually a valid definition; the notation id(x) = x does >> not make sense. It seems you are assuming that morphisms represent >> some sort of function, but that is only true in certain special >> categories. >> > > Ok, it is a valid definition only in a certain context. In the > far wider context of category theory this indeed makes no sense. > > > >>> My point is that in the books about category theory those two >>> statements are stated as axioms, and id is (in many books) just >>> self understood or defined as I have defined it above. >>> >>> If in a book about category the author would say that for each >>> object A there must exist a morphism id: A -> A (called identity >>> morphism) which is defined by idB . f = f and f . idA = f then this >>> would be clearer (and better, IMHO). >> >> This is exactly what category theory books do (or should) say. Do you >> have a particular example of a book which does not state things in >> this way? >> > > In 'Conceptual Mathematics' by F. William Lawvere, Stephen H. Schanuel > they define an identity map with fa = a for each a in A. > Then on page 17 they define category and say > > ... > Identity Maps: (one per object) 1A: A -> A > ... > Rules for a category > 1. The identity laws: > where they say g . 1A = g and 1B . f = f > 2. associatlve laws > ... > > It seems that this definition of a category is not as general as it > could be. Here 1. is something which follows easily from the definition > of an identity map. No. The point is that, by definition, a category, call it C, is a struct with two sets, Obj(C) and Mor(C), and further operations: 1. head: Mor(C) -> Obj(C) 2. tail: Mor(C) -> Obj(C) 3. id: Obj(C) -> Mor(C) 4. *: Mor(C) x Mor(C) -> Mor(C) where head and tail and id are everywhere defined single valued maps. They are all maps of sets. *, read "composition of morphisms" is a map of sets, with signature as displayed, but is not usually everywhere defined. We have then several "equational" axioms, which C is required to satisfy to be a category. (set theoretical note: We have, partly implicitly, ruled out categories which are not "small". See standard texts for this locus of difficulty.) By the axioms, any object b of C must have defined its associated identity morphism id[b]. For many categories, b will always be an actual set, and id[b] will be the unique map of sets defined by (id[b])(x) = x , for all x in b where (id[b])(x) is read "the result of applying id[b] to the element x of b". But, as explained, many categories have objects which are not sets. Indeed, often, no object is a set. The definition of category never mentions whether or not the objects are sets. And, as we have seen, there are many categories whose objects are not sets. (Perhaps categorically better: many categories are not directly presented as having objects which are sets.) to repeat: The concept "category" is larger in extension than the concept "category whose objects are sets and whose morphisms are maps of sets". ad representations of categories: http://en.wikipedia.org/wiki/Yoneda_Lemma [page was last modified on 1 April 2012 at 05:17] > > > I guess that this made me think of idA as idA(x) = x for each x of A. > Later when I saw other (more general) definitions I did not read > carefully to realize the difference. > > > Thanks a lot for making this clear to me. > > > -- > Manfred I will let stand my restatement of what you already know ;) oo--JS. ------------------------------ Message: 5 Date: Mon, 28 May 2012 20:44:18 +0200 From: Heinrich Apfelmus <apfel...@quantentunnel.de> Subject: Re: [Haskell-beginners] problems with wxHaskell installation To: beginners@haskell.org Message-ID: <jq0h22$gav$1...@dough.gmane.org> Content-Type: text/plain; charset=UTF-8; format=flowed Miguel Negrao wrote: > When I try to install wx after updating cabal it is failing on version > 0.90..0.1: > > miguelnegrao@Mac-Miguel:~$ cabal install wx > Resolving dependencies... > Configuring wx-0.90.0.1... > Preprocessing library wx-0.90.0.1... > Building wx-0.90.0.1... > [ 1 of 16] Compiling Graphics.UI.WX.Types ( src/Graphics/UI/WX/Types.hs, > dist/build/Graphics/UI/WX/Types.o ) > [ 2 of 16] Compiling Graphics.UI.WX.Attributes ( > src/Graphics/UI/WX/Attributes.hs, dist/build/Graphics/UI/WX/Attributes.o ) > [ 3 of 16] Compiling Graphics.UI.WX.Layout ( src/Graphics/UI/WX/Layout.hs, > dist/build/Graphics/UI/WX/Layout.o ) > [ 4 of 16] Compiling Graphics.UI.WX.Classes ( src/Graphics/UI/WX/Classes.hs, > dist/build/Graphics/UI/WX/Classes.o ) > [ 5 of 16] Compiling Graphics.UI.WX.Media ( src/Graphics/UI/WX/Media.hs, > dist/build/Graphics/UI/WX/Media.o ) > [ 6 of 16] Compiling Graphics.UI.WX.Events ( src/Graphics/UI/WX/Events.hs, > dist/build/Graphics/UI/WX/Events.o ) > [ 7 of 16] Compiling Graphics.UI.WX.Window ( src/Graphics/UI/WX/Window.hs, > dist/build/Graphics/UI/WX/Window.o ) > > src/Graphics/UI/WX/Window.hs:134:52: > Not in scope: `textCtrlChangeValue' > cabal: Error: some packages failed to install: > wx-0.90.0.1 failed during the building phase. The exception was: > ExitFailure 1 > > Does this mean that the package that was pushed to cabal has an > actual error ? How do I "use the latest patch level releases? of the > packages ? Jeremy forgot to narrow the version dependencies of the family of wx packages, not every combination that cabal accepts will actually work. The effect is that you have to reinstall the packages in the right order and with the right version number to get it to work. The following should do the trick cabal install wxdirect-0.90.0.1 cabal install wxc-0.90.0.3 cabal install wxcore-0.90.0.1 cabal install wx-0.90.0.1 The last number in the version number indicates bug fixes, that's why I refer to it as "patch-level". > Thanks for helping out. Seems I?m really unlucky with cabal and wxHaskell.. Not only you, I am afraid. In fact, I am tempted to purchase a lucky charm for cabal issues. Best regards, Heinrich Apfelmus -- http://apfelmus.nfshost.com ------------------------------ Message: 6 Date: Tue, 29 May 2012 00:19:56 +0530 From: kak dod <kak.dod2...@gmail.com> Subject: [Haskell-beginners] How to solve this using State Monad? To: beginners@haskell.org Message-ID: <CAJ4=wNH-3i9Kq7N46z1XQbNMAkfFaN_UWZAji3wGA0iQY=i...@mail.gmail.com> Content-Type: text/plain; charset="iso-8859-1" Hello, A very good morning to all. I am a Haskell beginner. And although I have written fairly complicated programs and have understood to some extent the concepts like pattern matching, folds, scans, list comprehensions, but I have not satisfactorily understood the concept of Monads yet. I have partially understood and used the Writer, List and Maybe monads but the State monad completely baffles me. I wanted to write a program for the following problem: A DFA simulator. This I guess is a right candidate for State monad as it mainly deals with state changes. What the program is supposed to do is: ====================== It should read a description of a DFA given as a 5 tuple (q, sigma, delta, q0, finals) where - q: a finite set of states - sigma: a finite set of input symbols called the alphabet - delta: a transition function (delta : Q ? S -> Q) - q0: start state (q0 belongs-to Q) - finals: a set of accept states (F belongs-to Q) def taken from wikipedia<http://en.wikipedia.org/wiki/Deterministic_finite_automaton#Formal_definition> and it should also read an input string (over alphabet sigma) and then it should run the input string on the DFA which it should build from the given description and should output (produce) a list of states through which the DFA has passed as it consumed the input string. You can assume that 'q' the set of state is of integers only. Also you can assume that sigma consist only of single character English alphabets ( ['A'..'Z']). The delta will be given as a list of 3-tuple. You don't need to do file IO. Sample input is following 2-tuple: input = (dfa, input-string) where dfa = ([0,1], ['A','B'], [(0,'A',0), (0,'B',1), (1,'A',1), (1,'B',0) ], 0, [1]) input-string = "AAABBABBAABBBABAAAB" Expected output: output = runDFA input -- output = [0,0,0,1,0,0,1,0,0,0,1,0,1,1,0,0,0,0,1] ====================== I wrote a recursive program to do this without using any monads. I simply send the entire dfa, the input string and its partial result in the recursive calls. How to do this using State Monad? Sorry, I may be a block-head but even after reading many tutorials on monads, I am still confused about the state monad. Either the tutorials give a very complicated example or they don't give a complete example that loads and runs properly in the GHCi . Again sorry to say, but the Random number generation example given in RealWorldHaskell didn't help me either. And yes, I have read Brent Yorgey's article on Monad tutorial fallacy too. So, you Monad gurus over here can consider me a block-head, but let me assure you people that I am a sincere person trying to learn this beautiful but difficult concept. I sincerely hope that a monadic solution (that uses Control.Monad.State ) to the DFA problem I gave, will help me understand the working of State Monad. Please note that I wish your solution to use the Control.Monad.State. Thanks in advance. kak -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://www.haskell.org/pipermail/beginners/attachments/20120529/f3fa1630/attachment.htm> ------------------------------ _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners End of Beginners Digest, Vol 47, Issue 25 *****************************************