Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Basic type classes like <code>Show</code>, <code>Eq</code> and <code>Ord</code> should be easy to grasp by reading the library documentation found by Hoogle and/or <a href="http://www.haskell.org/onlinereport/haskell2010/">Haskell-2010 Language Report</a>.</p> <p>The numeric tower in Haskell seems to be convoluted (<code>Int</code> type is an instance of whooping 11 type classes according to the report), but it is just to support all useful kinds of numbers and number representations mathematicians invented for us: e.g. <code>Integer</code> is a arbitrary size integer, <code>Int</code> is usual machine word-sized integer, and a lazy Peano representation of integers (not in standard library) proved useful in implementation of graph algorithms. The most important numeric type classes are <code>Num</code> and <code>Integral</code>. You can convert between different integer types by using <code>fromIntegral</code> functions. Note also that numerals such as 123 have type <code>Num a =&gt; a</code> and there's special type defaulting mechanism designed to reduce the need of type declarations to specify exact numeric type you need. In advanced use cases this works against you so you may want to alter the defaults.</p> <p>The same situation is with different types of strings: no single representation fits all, so many of them are in the wild: <code>String</code>, <code>Data.ByteString</code> and <code>Data.Text</code> are most important.</p> <p>Regarding more complicated type classes the best source is <a href="http://www.haskell.org/haskellwiki/Typeclassopedia">Typeclassopedia</a>.</p> <p>For certain type classes such as <code>Monad</code>, <code>Applicative</code> and <code>Arrow</code> there are a lot of dedicated tutorials and research works. Depending on your math skills, you may also want to read original research papers on the category theory concepts behind the type classes such as excellent "Notions of computation and monads" by Eugenio Moggi.</p> <p>As for "eta reductions" it is called <a href="http://www.haskell.org/haskellwiki/Pointfree">Point-Free Style</a>. You can get some information from the references mentioned at that link. You can also look at Combinatory Logic, a 1978 paper by John Backus <a href="http://www.cs.cmu.edu/~crary/819-f09/Backus78.pdf">Can programming be liberated from von neumann style?</a> and APL programming language to get a richer historical perspective on the point-free style.</p> <p>Also there are general books on Haskell such as 'A Gentle Introduction to Haskell' and 'Learn You a Haskell for Great Good'.</p> <p>As for operator precedence - there are really few operators you must remember: <code>(.)</code>, <code>($)</code> and <code>(&gt;&gt;=)</code> are used much more than everything else (barring arithmetics of course but arithmetic operators are rather unsurprising).</p> <p>The syntax for tuples and lists seems unproblematic for me too. It is just redundant: <code>foo : bar : []</code> is the same as <code>[foo, bar]</code> and <code>(,) foo bar</code> is the same as <code>(foo, bar)</code>. The prefix versions of tuples of higher arity such as <code>(,,,,)</code> are rarely used.</p> <p>See also <a href="http://www.haskell.org/haskellwiki/Section_of_an_infix_operator">http://www.haskell.org/haskellwiki/Section_of_an_infix_operator</a> for explanation of constructs such as <code>(+ 2)</code> and <code>(2 +)</code> called sections.</p> <p>Also you can learn from the changes the HLint tool suggests to improve your code. The HLint executable can be installed by <code>cabal install HLint</code>.</p> <p>As for advanced topics, I can recommend studying purely functional data structures (lets you design efficient immutable data structures and reason about time consumption), call by need lambda calculus (lets you reason about what is evaluated and in which order), System Fc type system (gives you some background on how haskell type checker works), denotational semantic (reasoning about non-termination, partiality and recursion, and also some insight on the notions of strictness, purity and composability).</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload