On 24/09/2013, at 9:02 AM, srean wrote: > On Mon, Sep 23, 2013 at 5:19 PM, john skaller > <skal...@users.sourceforge.net> wrote: >> >> On 24/09/2013, at 7:10 AM, srean wrote: >> >>> I call bollocks. >>
The bottom line is this: if you actually want to learn Felix you have to follow my instructions. Stop complaining about rants in the mailing list, stop reading a heap of crap. WRITE SOME CODE. Obey the instructions in the very first slide of the slideshow and first tutorial: you cannot learn a new programming language by reading documentation. You have to get your hands dirty. Read the docs AFTER you understand to firm up what you already know. Pick a problem such as "print the first 10 fibonacci numbers", implement it, and post your solution. Try another problem like "calculate the gcd of two numbers", which is Euclids algorithm. OK, so did you know, Euclid's algorithm doesn't just work for integers? It will work for a whole CLASS of structures called integral domains. SO now, you have a higher level problem: you already have Euclid's algorithm and you can change "int" to T to make it polymorphic but now it will not work. Try it! Why doesn't it work? Because + is not defined for T. So actually, you have to look up Wikipedia for Integral Domain and find out what one is, and define a type class for them. Which means adding the functions that are specified for an integral domain. If you want a model for the way this is done with classes you can look in the library, which defines groups and rings in lib/std/algebraic.flx Once you have an actual problem you can pattern match to guess how to use classes to solve the problem and keep trying until it works (or you have to ask for help). And since we don't have a class IntegralDomain[T] in the library .. we can then add it to the library :) Shayne managed to do this for something MUCH harder: he actually managed to get Monads to work in Felix. That requires a higher order operator which Felix just barely does support, When you have conceptual problems you may write some gibberish that fails and you just post it and I'll try to fix it. Do this enough times, you'll get the patterns right. The actual understanding (rather than just copy/paste) will come later. And even later .. the understanding of what the issues are with that technology. Some of the theoretical motivations for these things are quite deep. For example classes are strictly limited in what they can do. They're a kind of type level OO, and we KNOW that doesn't work. The RIGHT way to do this is to build your models on category theory, the way Ocaml does with modules and functors. That system is much more general but has two problems: its a pain to use, and, until Ocaml 3.12 at least you couldn't have module variables so functor arguments had to be literals. You probably don't understand that, but the constraint is that type classes only allow type arguments. They SHOULD allow class arguments, i.e. you should be able to parametrise a class with another class. In Ocaml you can. In particular you can thereby pass in function as well as type variables. You may not understand that constraint from a theoretical description but a practical example of it is easy to understand: with type classes you can provide integers with a total order relation < so 1 < 2 for example. Fine. But, what about the reverse order 2 < 1 This is a perfectly good total order., You could define that instead but you cannot have both together and there is no way to disambiguate. There is no problem with modules, because all uses have to provide the disambiguating indicator, which is the main problem with them: you have to provide that indicator even if there's only one case. Felix has classes instead of Ocaml like modules because it is intended as a scripting language and with that in mind the weaker but easier to use classes were chosen (after all if it's good enough for Haskell who am I to argue) -- john skaller skal...@users.sourceforge.net http://felix-lang.org ------------------------------------------------------------------------------ October Webinars: Code for Performance Free Intel webinars can help you accelerate application performance. Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from the latest Intel processors and coprocessors. See abstracts and register > http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk _______________________________________________ Felix-language mailing list Felix-language@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/felix-language