opinions-tech-haskell

notes for a future post


purpose

already a year out of date

difficult, two sources: different complex

language updates

memory strict

python examp

no typecasting boolean typecasting -> unreadable helpers

unreadable helpers

haskell collection are a mess

error messages

docs vs irc

homeoiconic, macros

static complexity

open data Open Data Types and Open Functions like 5 different frameworks to alleviate this no really generic (parsec needs to be rewritten to use ByteString??)

python/ruby compile to haskell

connection machines, non-composability of locks, next mainstream, functional is the right default


--- i think this is wrong : "execution ordering" annotation (do the parallel libraries already do this?). for example, say i have a very large file. i am parsing it line by line. each line generates two data objects, of types A and B. A objects and B objects are being fed into separate paths of data transformation (A -> A' -> A -> A, and B -> B' -> B -> B). The first two steps operate on individual X objects, but the final step in each path requires combining all of the X objects (that is to say, if you consider the list [A] of A objects, the first two steps are maps and the last one is a fold). After an A object has been turned into an A object, the A path has no more need of the original strings from the original input line. Similarly, after a B object has been turned into a B' object, the B path doesn't need the strings.

Now, my impression is that currently, Haskell is allowed to (and often will choose to) execute A -> A', and then A' -> A, and then A -> A. While it is doing this, however, it will read in the entire input file, and keep every line of it in memory because it knows that eventually it will have to compute the Bs, and the Bs depend on the lines.

What the programmer wants it to do is to process each line of input separately and then forget about it. But the programmer doesn't want to let this dirty, real-world concern affect the beauty of hir code; the programmer wants to keep the description of the a pipeline and the B pipeline totally separate, in separate functions, as much as possible.

So, what is needed is an way for the programmer to write these pipelines separately, and then only commingle them in a single place, by telling the compiler explicitly about the sad facts of life. The programmer should be able to annotate the string object created by reading in the line; the programmer wants to say, "once this thunk has been evaluated, you may execute neither the "A->A" function, nor the "B->B" function, until you have strictly executed both of "A'->A" and "B'->B". This can be effected by tricking the compiler into thinking that the following dependencies exist:

(note: you could do that by adding "seqs" to A->A and B->B, i guess..)


haskell overloading typeclass disallowed example

(also example of an error which is caught at compile time, but not until you try and use the ambiguous construct)

in file tst.hs:

data Dumbtype a b = Dumbtype a b

Nothin a b

instance Monad (Dumbtype a) where return r = Dumbtype undefined r Dumbtype a f >>= k = k f Nothin a f >>= k = k f

instance Monad (Dumbtype Char) where return r = Nothin 'a' r Dumbtype a f >>= k = k f Nothin a f >>= k = k f

:l tst

<interactive>:1:4: Overlapping instances for Monad (Dumbtype Char) arising from a use of `return' at <interactive>:1:4-13 Matching instances: instance Monad (Dumbtype a) -- Defined at tst.hs:(17,0)-(20,29) instance Monad (Dumbtype Char) -- Defined at tst.hs:(23,0)-(26,29) In the expression: return 'y' In the expression: do return 'y' :: Dumbtype Char Char In the definition of `it': it = do return 'y' :: Dumbtype Char Char


haskell typeclass debugging? example: I was looking at the expression "((*) >>= id) f", where f is of type String -> Int. Control.Arrow had been imported. I was wondering what kind of monad was being applied here, that is, which instance definition for typeclass Monad was defining ">>=" in my expression. The answer seems to be that Control.Arrow imports Control.Monad.Fix, which imports Control.Monad.Instances, which contains a Monad instance for functions.

Is there a way to ask GHCI to tell me the file in which it is finding the instance definition that it is using in a given expression? If not, then is there a way to ask GHCI to list all instance definitions currently accessible? Or, at least, a way to ask GHCI to list all files currently accessible (i.e. all modules loaded, as well as all modules imported by those modules, etc)? Thanks.

How do you do that? I'm hoping for something akin to :info, that will tell me, "in this expression, the >>= that is being used is found in file Control.Arrow".

Also, is there a way to get an evaluation

---

haskell notes:

(Num a, OnlyInts? a)

class OnlyInts? a where foo :: a -> a -> Bool

instance OnlyInts? Int where foo = (==)

bar :: (Num a, OnlyInts? a) => a -> Bool bar = foo 5

http://homepages.cwi.nl/~ralf/gpce06/ http://www.haskell.org/haskellwiki/Why_Haskell_matters http://www.haskell.org/haskellwiki/OOP_vs_type_classes http://www.cs.chalmers.se/~rjmh/Papers/whyfp.html

http://www.haskell.org/tmrwiki/FpVsOo

let cross2 l1 l2 = do {x <- l1; y <- l2; if x < y then return (x,y) else fail ""} why doesn't this work: let cross2 l1 l2 = do {x <- l1; y <- l2; if x < y then return (x,y) else return ()} A: [()] != [] :t cross2

let cross3 l1 l2 = do {x <- l1; y <- l2; if x < y then return x*y else fail ""}

:t cross3