Re: [Haskell-cafe] Is there any experience using Software Transactional Memory in substantial applications?

2010-08-08 Thread Johnny Morrice
> My opponent gave me that link:
http://logicaloptimizer.blogspot.com/2010/06/so-microsofts-experiments-with-software.html

I enjoy the article you linked but I sort of skimmed it because it was a
little boring, however its main point seem to be:

1. Ghostbusters.
2. Artificial intelligence is useless [1]
3. Listen to Anders! [2]

An interesting sample:

"Anders Hejlsberg: Well, the best Software
Transactional Memory implementations are still sitting
at around 200% to 400% and that's even in best
cases actually and still with Software Transactional
Memory it's still, in a sense, it's still a problem of
synchronization and shared state which...

Carl Franklin:
It's just under the lower level.

Anders Hejlsberg: Some would argue it's t h e
wrong way to look at the problem in the beginning.
We shouldn't have the shared state to begin with.

Richard Campbell: Right.

Hat guy from xkcd (Enter stage left): But don't you see that Haskell has
no shared state.  That's exactly why STM is so great for doing
concurrency in Haskell!"

(I maybe edited that a little there.)

Ta ta,
   Johnny

[1] Artificial intelligence is pointless
http://www.youtube.com/watch?v=nvZBtJ-ncEM

[2] The internet audio talkshow
http://www.dotnetrocks.com/default.aspx?showNum=541
I found this transcript on google.  Server seems to give of fake 404
pages, so have to hotlink :(
http://perseus.franklins.net/dotnetrocks_0541_anders_hejlsberg.pdf



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Announce snm-0.0.2: Oops

2010-07-27 Thread Johnny Morrice
> Sorry if I have left typos, it's very late

I knew it was a bit late to be uploading things, I forgot to say where
anyone interested might download this:  

it's on Hackage so just 

cabal install snm

Cheers
   Johnny



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Announce snm-0.0.2: The Simple Nice-Looking Manual Generator

2010-07-26 Thread Johnny Morrice
Hi list,

Recently, I've been working on a compiler/programming language
project.[2]

I became rather unstuck when I started spending more time documenting
the semantics instead of actually getting to work on the implementation.

Hence this program!

snm allows you to write clean, web-friendly reports, user guides and
manuals without having to edit fickle html.

snm allows you to structure your document in a modular fashion.

snm document sections are written in yaml and are easy to write and
understand.

snm is a generator of small, valid xhtml files.

Read the snm user guide here:
http://www.killersmurf.com/static/snm_help.html

snm uses Yaml and generates XHTML, so it's a little like John
MacFarlane's yst[1], but yst is for making websites, while snm is
exclusively for creating structured reports.

It still has a lot of problems, not to mention no support for images, or
multiple pages, but I'm finding it usable (enough to document itself!)
so I thought it best to share :)

Sorry if I have left typos, it's very late

Have fun,
   Johnny


[1] John MacFarlane's yst: http://hackage.haskell.org/package/yst
[2] Yon aforementioned programming language project, in case anyone
fancies a peep.  Demoted to reference #2, on account of it not yet
compiling code :) http://github.com/elginer/Obelisk

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Adding new entry to list

2010-07-08 Thread Johnny Morrice
Hi there Jack,

I have modified your program.  However, where you were attempting to use
direct recursion to compute totalSales, I have used functions from the
prelude.

I have also provided a recursive definition totalSalesRec.

Here is a lesson on recursion from the Haskell wikibook
http://en.wikibooks.org/wiki/Haskell/Recursion

Also, what you have is an associative array which pairs (Artist, Title)
with Sold.  A linked list [(Artist, Title, Sold)] is an inappropriate
data type for this purpose.  Consider using Map from Data.Map in the
form Map (Artist, Title) Sold.

I have included comments which I hope you will find useful in
understanding the code.

Also note my use of comments like:

-- | This is a function that does blah

These are annotations for the Haskell documention generator, Haddock
http://www.haskell.org/haddock/

What I'd do to run haddock on this file (I use linux and I have saved as
artist.hs) is

mkdir doc && haddock artist.hs -o doc -h

Now you can look at documentation for your program in a web browser
while fickering with it in GHCi.

Be aware that my copy pasting this file onto here may well have mangled
its syntax!

Have fun,
   Johnny

module Main
   (main
   ,testDatabase
   ,totalSales
   ,totalSalesRec
   ,printNames
   ,mainLoop)
   where

-- | Title of a record
type Title = String
-- | An artist, who makes records
type Artist = String
-- | Number of copies of a record sold
type Sold = Int

type Sales = [(Title, Artist, Sold)]

-- | A small sales database
testDatabase :: Sales
testDatabase = [("Kids", "MGMT", 3), ("This Charming Man", "The Smiths",
5), ("Gimme Shelter", "The Rolling Stones", 7)]

-- Notice there are no explicit function arguments here.  Look up
'partial application'.
-- | Total sales of all records in the database.
totalSales :: Sales -> Sold 
totalSales =
   -- The sum of all the sales
   sum . map sale
   where
   sale (_,_,s) = s

-- | Recursive version of totalSales
totalSalesRec :: Sales -> Sold
totalSalesRec ((_,_,s):ss) = s + totalSalesRec ss
totalSalesRec _= 0

-- | Print out the contents of a sales database
printNames :: Sales -> IO ()
printNames testDatabase = mapM_ print testDatabase

-- Main application loop
mainLoop :: Sales -> IO ()
mainLoop testDatabase = do
putStrLn "1 - Show all tracks in database"
putStrLn "2 - Show the total sales"
putStrLn "3 - Add a new entry"
putStrLn "4 - Exit"
putStrLn ""
putStrLn "Please select an option:"
input <- getLine
case read input of
1 -> do
banner "Show All Tracks"
printNames testDatabase
putStrLn ""
mainLoop testDatabase
2 -> do 
banner "Total Sales"
print $ totalSales testDatabase
putStrLn ""
mainLoop testDatabase
3 -> do
banner "New entry"
putStrLn "Enter artist name"
a <- getLine
putStrLn ""
putStrLn "Enter title"
t <- getLine
putStrLn ""
putStrLn "Enter number of sales"
-- Look up functors to understand fmap
s <- fmap read getLine
putStrLn ""
-- 'cons' the new element to the start
of the linked list testDatabase
-- Look up data constructors.
mainLoop $ (a,t,s) : testDatabase
-- No 'do' is required for only one statement.
Look up monads and how 'do' is syntactic sugar. 
4 -> return ()
   where
   -- Print banner
   banner s = do
 putStrLn "--"
 putStrLn s
 putStrLn "--"

-- | Run
main :: IO ()
main = mainLoop testDatabase

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Haskell-Cafe Digest, Vol 75, Issue 51

2009-11-24 Thread Johnny Morrice
> 1) the uncensored version
> 2) Monadam*
> 3) Monada**
> 4) Monad***
> 5) Mona

Putting stars in place of letters in no way makes a word less offensive.
Consider the word 'ing'.

It's about context.  I think it's wise that such a word have a star put
in it in the weekly news or a journal article as it shows the author is
less bombastic and doesn't want to use loud language - which counts for
a lot in other's opinions.

Johnny

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Typefuck: Brainfuck in the type system

2009-11-16 Thread Johnny Morrice
My personal opinion is that such f-bombs really have no place on what is
a font of software dissemination.

My point of view is a fallacy however.  Consider a new, viable
programming language which has a syntax based entirely on GG-Allin
lyrics.  

Obviously this would disgust a decent programmer (aren't we all
decent :)  

One would be pressed to prove that this new language has no scientific
value only in order to avoid his disgusting poetry, which could be
difficult (and perhaps pointless, which would be worse than difficult)

But I think I am fuzzing out beyond what the point of this originally
was... yes - this discussion reminds me of both Wadler's law and the
phenomenon of Cargo Cults, as according to the Wiki Wiki web (see
http://c2.com/cgi/wiki?CargoCult) -- what I mean by this is that however
it might be labelled on a software archive, such a program is surely and
deeply ed.

Johnny

On Mon, 2009-11-16 at 12:28 -0500, Joe Fredette wrote:
> Well then, send it up to the great Hackage machine! If the f-bombs are  
> allowed...
> 
> I think my package names are about to get alot less SFW...
> 
> 
> 
> On Nov 16, 2009, at 12:26 PM, Gwern Branwen wrote:
> 
> > On Mon, Nov 16, 2009 at 12:23 PM, Joe Fredette   
> > wrote:
> >> Awesome, however, I don't know what the policy is for such --  
> >> interesting --
> >> names on Hackage. Normally I believe the response to "Should I put  
> >> it on
> >> Hackage" is a resounding, immediate "Absolutely." In this case,  
> >> perhaps a
> >> small name change to avoid any possibility of offense?
> >>
> >> /Joe
> >
> > Too late:
> > http://hackage.haskell.org/package/brainfuck
> > http://hackage.haskell.org/package/loli
> >
> > -- 
> > gwern
> 


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Typefuck: Brainfuck in the type system

2009-11-16 Thread Johnny Morrice
Greetings list,

I was um well, drinking beer and thought it would be amusing to write a
brainfuck interpreter which runs within the GHC type checker so I did,
using type families.

I haven't decided whether or not to put it on hackage (it is rather
silly after all) but I have a link to a cabalized package and
instructions on how to work it in an entry on my blog, here:
http://killersmurf.blogspot.com/2009/11/typefuck.html

Enjoy the ridiculousness.

Johnny

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe