[Haskell-cafe] Hoogle problems?

2013-07-15 Thread Andrew Butterfield
I've just tried using Hoogle, but either get a 404 not found
(http://haskell.org/hoogle/) or else I find I get a ELF 64-bit
LSB executable being downloaded

If I search using Google and click on the first link 
(shown as www.haskell.org/hoogle/
I get the following (spaces deliberately added to make it less dangerous)
https://www.goo gle.com/url?sa=trct=jq=esrc=ssou 
rce=webcd=1cad=rjaved=0CC8QFjAAurl=http%3A%2F%2Fwww.haskell.org%2Fhoogle%2Fei=y_njUdZAhY
 7sBsGpgNAKusg=AFQjCNFljq5Oyb4LT7VF-I5MUotq512AQgsig2 
=SVRE_6nF3bhho7-NKqEaCwbvm=bv.487 05608,d.ZGU

Using Mac OS X 10.6, Chrome and Safari

Is it me, or is there a wider problem ?

Andrew Butterfield Tel: +353-1-896-2517 Fax: +353-1-677-2204
Lero@TCD, Head of Foundations  Methods Research Group
Director of Teaching and Learning - Undergraduate,
School of Computer Science and Statistics,
Room G.39, O'Reilly Institute, Trinity College, University of Dublin
  http://www.scss.tcd.ie/Andrew.Butterfield/



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


Re: [Haskell-cafe] mapFst and mapSnd

2013-05-28 Thread Andrew Butterfield
I have them defined for my stuff.

Generally I find it much quicker  to roll my own than to
(1) ask on this list if someone else has done it...
(2) look at arrows or 
MyFavouriteCategoryTheoryBitOfFPBecauseICantGetAbstractEnough
and the try to figure out what is going on.

The joy of Haskell is both that rolling your own is often so easy,
and that there are lots of approaches out there that allow you to get abstract 
as well...


Regards,
  Andrew (Engineering graduate, feet still firmly embedded in concrete :-)



On 28 May 2013, at 09:54, Dominique Devriese wrote:

 Hi all,
 
 I often find myself needing the following definitions:
 
  mapPair :: (a - b) - (c - d) - (a,c) - (b,d)
  mapPair f g (x,y) = (f x, g y)
 
  mapFst :: (a - b) - (a,c) - (b,c)
  mapFst f = mapPair f id
 
  mapSnd :: (b - c) - (a,b) - (a,c)
  mapSnd = mapPair id
 
 But they seem missing from the prelude and Hoogle or Hayoo only turn
 up versions of them in packages like scion or fgl.  Has anyone else
 felt the need for these functions?  Am I missing some generalisation
 of them perhaps?
 
 Regards,
 Dominique
 
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe


Andrew Butterfield Tel: +353-1-896-2517 Fax: +353-1-677-2204
Lero@TCD, Head of Foundations  Methods Research Group
Director of Teaching and Learning - Undergraduate,
School of Computer Science and Statistics,
Room G.39, O'Reilly Institute, Trinity College, University of Dublin
  http://www.scss.tcd.ie/Andrew.Butterfield/



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


Re: [Haskell-cafe] Teaching FP with Haskell

2013-05-21 Thread Andrew Butterfield
Rustom,
 you should look at Helium
  - http://www.cs.uu.nl/wiki/bin/view/Helium/WebHome


Andrew.

On 21 May 2013, at 10:55, Rustom Mody wrote:

 We are offering a MOOC on haskell :
 https://moocfellowship.org/submissions/the-dance-of-functional-programming-languaging-with-haskell-and-python
 
 Full Announcement on beginners list :
 http://www.haskell.org/pipermail/beginners/2013-May/012013.html
 
 One question that I have been grappling with in this regard:
 How to run ghc in lightweight/beginner mode?
 
 2 examples of what I mean:
 
 1. gofer used to come with an alternative standard prelude -- 'simple.pre'
 Using this, gofer would show many of the type-class based errors as 
 simple (non-type-class based) errors.
 This was very useful for us teachers to help noobs start off without 
 intimidating them.
 2. Racket comes with a couple of levels.  The easier numbers were not 
 completely consistent with scheme semantics, but 
 was gentle to beginners
 
 Any thoughts/inputs on this will be welcomed
 
 Rusi
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe


Andrew Butterfield Tel: +353-1-896-2517 Fax: +353-1-677-2204
Lero@TCD, Head of Foundations  Methods Research Group
Director of Teaching and Learning - Undergraduate,
School of Computer Science and Statistics,
Room G.39, O'Reilly Institute, Trinity College, University of Dublin
  http://www.scss.tcd.ie/Andrew.Butterfield/


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


Re: [Haskell-cafe] Markdown extension for Haddock as a GSoC project

2013-05-02 Thread Andrew Butterfield
My 2c (before such coins disappear...)

On 2 May 2013, at 09:14, Petr Pudlák wrote:

 Hi,
 
 
 Personally I'd incline to choose some existing, well-established markup 
 language with formal specification that supports math (hopefully there is 
 one).

So TeX/LaTeX is out then   :-(




Andrew Butterfield Tel: +353-1-896-2517 Fax: +353-1-677-2204
Lero@TCD, Head of Foundations  Methods Research Group
Director of Teaching and Learning - Undergraduate,
School of Computer Science and Statistics,
Room G.39, O'Reilly Institute, Trinity College, University of Dublin
  http://www.scss.tcd.ie/Andrew.Butterfield/


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


Re: [Haskell-cafe] GSoC Project Proposal: Markdown support for Haddock

2013-04-05 Thread Andrew Butterfield

On 4 Apr 2013, at 22:53, Aleksey Khudyakov wrote:

 If we are going to change haddock syntax we should add ability to add
 math formulae to documentation. It's not currently possible and it makes
 documenting numeric code properly difficult.

How about support for .lhs files?
 - both those with bird-tracks (which I don't use anymore)
   and \begin{code}...\end{code} (which I do use).

My .lhs files are also LaTeX sources - I guess some way to nicely integrate
haddock markup/down/whatever with LaTeX stuff would be needed

+1 in any case

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


Andrew Butterfield Tel: +353-1-896-2517 Fax: +353-1-677-2204
Lero@TCD, Head of Foundations  Methods Research Group
Director of Teaching and Learning - Undergraduate,
School of Computer Science and Statistics,
Room G.39, O'Reilly Institute, Trinity College, University of Dublin
  http://www.scss.tcd.ie/Andrew.Butterfield/



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


Re: [Haskell-cafe] GSoC Project Proposal: Markdown support for Haddock

2013-04-05 Thread Andrew Butterfield
I'm not proposing the LaTeX is used for hyperlinking the
reference  -  hence my comment about nicely integrating

Perhaps a \begin{haddock} ... \end{haddock} environment* ?

* This would only affect those using LaTeX/lhs - everyone else could haddock** 
as usual

** haddock = whatever markdow/up/sideways scheme you guys come up with...


On 5 Apr 2013, at 16:22, Aleksey Khudyakov wrote:

 On 5 April 2013 12:20, Andrew Butterfield
 andrew.butterfi...@scss.tcd.ie wrote:
 
 On 4 Apr 2013, at 22:53, Aleksey Khudyakov wrote:
 
 If we are going to change haddock syntax we should add ability to add
 math formulae to documentation. It's not currently possible and it makes
 documenting numeric code properly difficult.
 
 How about support for .lhs files?
 - both those with bird-tracks (which I don't use anymore)
   and \begin{code}...\end{code} (which I do use).
 
 My .lhs files are also LaTeX sources - I guess some way to nicely integrate
 haddock markup/down/whatever with LaTeX stuff would be needed
 
 I'm not sure that it would help. If we to use haddock markup it need to
 support math typesetting. And LaTeX IMHO isn't right tool for creating
 hyperlinked API reference
 
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe


Andrew Butterfield Tel: +353-1-896-2517 Fax: +353-1-677-2204
Lero@TCD, Head of Foundations  Methods Research Group
Director of Teaching and Learning - Undergraduate,
School of Computer Science and Statistics,
Room G.39, O'Reilly Institute, Trinity College, University of Dublin
  http://www.scss.tcd.ie/Andrew.Butterfield/



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


Re: [Haskell-cafe] What Haskell Records Need

2012-08-02 Thread Andrew Butterfield

On 2 Aug 2012, at 09:25, Erik Hesselink wrote:

 Isn't this exactly the problem solved by all the lens packages?
 Current popular ones are fclabels [0] and data-lens [1].
 
 [0] http://hackage.haskell.org/package/fclabels
 [1] http://hackage.haskell.org/package/data-lens

Not sure what all of these do, but I have a simple solution I use
in my work:
 
 Take the following types from a contrived
 example.
 
 type Salary = Integer
 
 data Job = Job
 { title  :: String
 , salary :: Salary
 }

Rather than setTitle :: String - Job - Job  we lift the first argument
and define

setfTitle  :: (String - String) - Job - Job
setfTitle f jobrec = jobrec{ title = f $ title jobrec }

then setTitle = setfTitle . const

This is all just boilerplate, so we continue

setfSalary :: (Salary - Salary) - Job - Job
setfSalary f jobrec = jobrec{ salary = f $ salary jobrec }

 
 data Person = Person
 { name :: String
 , job  :: Job
 }
 


setfName :: (String - String) - Person - Person
setfName f prec = prec{ name = f $ name prec }

setfJob :: (Job - Job) - Person - Person
setfJob f prec = prec{ job = f $ job prec }

Now we can use function composition to do two levels

setfTitleInPerson :: (String - String) - Person - Person
setfTitleInPerson = setfJob . setfTitle

setTitleInPerson :: String - Person - Person
setTitleInPerson = setfTitleInPerson . const

Simple function composition works to put these together...


I was frustrated by this problem a while back, and decided to approach it 
formally
(I write literate Haskell/LateX documents), and went to work, doing the math
with the intention of writing a suitable combinator, until I discovered I didn't
need one  lifting from  X - R - R   to (X - X) - R - R gave me all I 
needed...



 Since I've used record syntax, I get
 getter/accessor functions (title, salary,
 name, job) for free. Now suppose I want to
 create an aggregate getter function: return
 the salary of a given person. Piece of cake,
 it's just function composition
 
 getSalary :: Person - Salary
 getSalary = salary . job
 
 Done! Now suppose I want to write a
 setter/mutator function for the same nested
 field
 
 setSalaryMessy :: Salary - Person - Person
 setSalaryMessy newSalary person =
 person {
  job = (job person) {
salary = newSalary
  }
 }
 
 Ouch! And that's not even very deeply nested.
 Imagine 4 or 5 levels deep. It really makes
 Haskell feel clunky next to `a.b.c.d = val`
 that you see in other languages. Of course
 immutability means that the semantics of
 Haskell are quite different (we're creating
 new values here, not updating old ones) but
 it's still common to model change using these
 kinds of updates.
 
 What if along with the free getters that
 the compiler generates when we use record
 syntax, we also got semantic editor
 combinator (SEC) functions[0] that could be
 used as follows?
 
 setSalary newSalary = job' $ salary' (const newSalary)
 
 giveRaise amount = job' $ salary' (+amount)
 
 givePercentRaise percent = job' $ salary' (*(1+percent))
 
 For each field x, the compiler generates a
 function x' (the tic is mnemonic for change).
 These little functions aren't hard to write,
 but they're classic boilerplate.
 
 job' :: (Job - Job) - Person - Person
 job' f person = person {job = f $ job person}
 
 salary' :: (Salary - Salary) - Job - Job
 salary' f job = job { salary = f $ salary job}
 
 These type of utility functions are a dream
 when working with any reference type or
 State Monad.
 
 modify $ givePercentRaise 0.25
 
 The compiler could also generate polymorphic
 SEC functions for polymorphic fields.
 Further, the compiler could disallow using
 old-style update syntax for fields whose SEC
 update function is not in scope, giving us
 fine-grained control over access and update.
 On the other hand we currently have to create
 new functions to achieve this (exporting the
 getter means exporting the ability to update
 as well, currently).
 
 Of course this doesn't address the
 namespacing issues with records, but it is
 likely nicely orthogonal to other proposals
 which do.
 
 Also note that there's a package on hackage [1]
 that will generate SEC functions using TH.
 It's nice, but I prefer the style of field
 names used above for updaters (field' vs
 editField).
 
 Let me know what you think. I'll write up an
 official proposal if there's a bit of
 general interest around this.
 
 Thanks for reading,
 
 --Jonathan
 
 [0] - http://conal.net/blog/posts/semantic-editor-combinators
 [1] -
 http://hackage.haskell.org/packages/archive/sec/0.0.1/doc/html/Data-SemanticEditors.html
 
 
 
 
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe
 
 
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe


Andrew Butterfield

Re: [Haskell-cafe] What Haskell Records Need

2012-08-02 Thread Andrew Butterfield
Ah yes - the joy of Haskell

It so easy to roll your own, rather than search to find someone else's
(better/more elegant) solution...   :-)


On 2 Aug 2012, at 11:41, Erik Hesselink wrote:

 On Thu, Aug 2, 2012 at 12:30 PM, Andrew Butterfield
 andrew.butterfi...@scss.tcd.ie wrote:
 
 On 2 Aug 2012, at 09:25, Erik Hesselink wrote:
 
 Isn't this exactly the problem solved by all the lens packages?
 Current popular ones are fclabels [0] and data-lens [1].
 
 [0] http://hackage.haskell.org/package/fclabels
 [1] http://hackage.haskell.org/package/data-lens
 
 Not sure what all of these do, but I have a simple solution I use
 in my work:
 
 They do exactly that. They create 'lenses' which are
 getters/setters/modifiers combined, and allow you to compose these to
 get/set/modify deep inside nested data types. Look at the examples in
 the fclabels documentation [2] for more details.
 
 [2] 
 http://hackage.haskell.org/packages/archive/fclabels/1.1.4/doc/html/Data-Label.html


Andrew Butterfield Tel: +353-1-896-2517 Fax: +353-1-677-2204
Lero@TCD, Head of Foundations  Methods Research Group
Director of Teaching and Learning - Undergraduate,
School of Computer Science and Statistics,
Room G.39, O'Reilly Institute, Trinity College, University of Dublin
  http://www.scss.tcd.ie/Andrew.Butterfield/



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


Re: [Haskell-cafe] I Need a Better Functional Language!

2012-04-05 Thread Andrew Butterfield

On 5 Apr 2012, at 15:14, Grigory Sarnitskiy wrote:

 Hello! I've just realized that Haskell is no good for working with functions!
 
 
 
 Obviously, that's not all of the imaginable possibilities. One also can 
 rewrite programs. And write programs that rewrite programs. And write 
 programs that rewrite programs that rewrite the first programs and so on. But 
 there is no such possibility in Haskell, except for introducing a DSL.
 
 So now I wonder, what are the languages that are functional in the sense 
 above? With a reasonable syntax and semantics, thus no assembler. I guess 
 Lisp might be of this kind, but I'm not sure.

Probably - but the semantics is dreadful...

 
 
 Note, that the reflectivity is important.

Intel developed a reflective functional language/system called Forte that is 
the basic
of a lot of their formal hardware verification process...

  http://www.cs.ox.ac.uk/tom.melham/res/forte.html


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


Andrew Butterfield Tel: +353-1-896-2517 Fax: +353-1-677-2204
Lero@TCD, Head of Foundations  Methods Research Group
Director of Teaching and Learning - Undergraduate,
School of Computer Science and Statistics,
Room G.39, O'Reilly Institute, Trinity College, University of Dublin
  http://www.scss.tcd.ie/Andrew.Butterfield/



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


Re: [Haskell-cafe] I Need a Better Functional Language!

2012-04-05 Thread Andrew Butterfield
Addendum:

Intel's Forte was the framework,

reFLect was the language :  http://www.cs.ox.ac.uk/tom.melham/res/reflect.html

Quoting that page:
reFLect is a functional programming language designed and implemented by a 
team at Intel Corporation's Strategic CAD Labs under the direction of Jim 
Grundy. The language is strongly typed and similar to ML, but provides certain 
reflection features intended for applications in industrial hardware design and 
verification. Like LISP, reFLect has quotation and antiquotation constructs 
that may be used to construct and decompose expressions in the language itself. 
Unlike LISP, these mechanisms are typed. The language also provides a primitive 
mechanism for pattern-matching, and in particular for defining functions over 
code by pattern-matching on the structure of reFLect expressions.

 
On 5 Apr 2012, at 15:14, Grigory Sarnitskiy wrote:

 Hello! I've just realized that Haskell is no good for working with functions!
 
 First, what are 'functions' we are interested at? It can't be the usual 
 set-theoretic definition, since it is not constructive. The constructive 
 definition should imply functions that can be constructed, computed. Thus 
 these are computable functions that should be of our concern. But computable 
 functions in essence are just a synonym for programs.
 
 One could expect from a language that bears 'functional' as its 
 characteristic to be able to do everything imaginable with functions. 
 However, the only thing Haskell can do with functions is to apply them to 
 arguments and to feed them as arguments, run in parallel (run and concatenate 
 programs).
 
 Obviously, that's not all of the imaginable possibilities. One also can 
 rewrite programs. And write programs that rewrite programs. And write 
 programs that rewrite programs that rewrite the first programs and so on. But 
 there is no such possibility in Haskell, except for introducing a DSL.
 
 So now I wonder, what are the languages that are functional in the sense 
 above? With a reasonable syntax and semantics, thus no assembler. I guess 
 Lisp might be of this kind, but I'm not sure. In addition, I'm not a fan of 
 parentheses. What else? Pure? Mathematica? Maxima?
 
 Note, that the reflectivity is important.
 
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe


Andrew Butterfield Tel: +353-1-896-2517 Fax: +353-1-677-2204
Lero@TCD, Head of Foundations  Methods Research Group
Director of Teaching and Learning - Undergraduate,
School of Computer Science and Statistics,
Room G.39, O'Reilly Institute, Trinity College, University of Dublin
  http://www.scss.tcd.ie/Andrew.Butterfield/



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


Re: [Haskell-cafe] interest in Irish Haskell User's Group?

2012-01-24 Thread Andrew Butterfield
Count me in ! (i've also CCed a colleague)

On 24 Jan 2012, at 11:27, John Lato wrote:

 Hello,
 
 Some other Haskellers and I have been discussing starting an Irish
 Haskell User's Group.  I think we're close to critical mass, and need
 just a few more interested people to give it a run.  To that end, I'd
 appreciate hearing from anyone who would be interested in attending or
 participating.
 
 Our initial meeting would likely be in Maynooth as that's where we're
 based, however we'd like to see involvement across at least the
 greater Dublin area, and possibly further afield.
 
 So, please let me know if you're interested in participating.  I'll
 post further details when we've established an initial meeting.
 
 Thanks,
 John L.
 
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe


Andrew Butterfield Tel: +353-1-896-2517 Fax: +353-1-677-2204
Lero@TCD, Head of Foundations  Methods Research Group
Director of Teaching and Learning - Undergraduate,
School of Computer Science and Statistics,
Room G.39, O'Reilly Institute, Trinity College, University of Dublin
  http://www.scss.tcd.ie/Andrew.Butterfield/



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


Re: [Haskell-cafe] black Wikipedia (Was: PhD program at Portland State accepting applications)

2012-01-18 Thread Andrew Butterfield
Just add ?banner=none to the url if you really have to read the page

On 18 Jan 2012, at 17:37, Henning Thielemann wrote:

 
 On Wed, 18 Jan 2012, Nathan Collins wrote:
 
 - Portland is a very popular US city, known for beer, bikes, music,
 and street food:
 
 http://en.wikipedia.org/wiki/Portland_Oregon (wikipedia is blacked out today)
 
 Maybe it is only a JavaScript trick. In Firefox (with JavaScript) I see the 
 complete a page before it is overwritten by the protest page. In Konqueror of 
 KDE 3 (with and without JavaScript) I can read the Wiki pages without 
 problems. Edit however is really disabled. Sometimes I am glad to have the 
 old technology available. :-)
 
 
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe


Andrew Butterfield Tel: +353-1-896-2517 Fax: +353-1-677-2204
Lero@TCD, Head of Foundations  Methods Research Group
Director of Teaching and Learning - Undergraduate,
School of Computer Science and Statistics,
Room G.39, O'Reilly Institute, Trinity College, University of Dublin
  http://www.scss.tcd.ie/Andrew.Butterfield/



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


Re: [Haskell-cafe] Program used for debugging

2011-12-01 Thread Andrew Butterfield

On 1 Dec 2011, at 14:10, Yves Parès wrote:

 Hey,
 
 What do you mostly use for debugging?
 Simple calls to Debug.Trace.trace? Hpc? Hood?

Debug.Trace, with some short helpers

so  
 dbg x= x  
displays the value of x, provided x is in Show

import Debug.Trace

dbg msg x = dbgsh show msg x
dbgsh sh msg x = trace (msg++sh x) x
cdbg p msg x
 | p x=  dbg msg x
 | otherwise  =  x

-- if you want to tailor the show:
class Dshow t where dshow :: t - String
ddbg msg x = dbgsh dshow msg x
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe


Andrew Butterfield Tel: +353-1-896-2517 Fax: +353-1-677-2204
Lero@TCD, Head of Foundations  Methods Research Group
Director of Teaching and Learning - Undergraduate,
School of Computer Science and Statistics,
Room G.39, O'Reilly Institute, Trinity College, University of Dublin
  http://www.scss.tcd.ie/Andrew.Butterfield/


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


Re: [Haskell-cafe] A Mascot

2011-11-16 Thread Andrew Butterfield

On 16 Nov 2011, at 08:46, Ertugrul Soeylemez wrote:

 
 But I think, despite the well-founded denotational semantics of Haskell,
 bottom does not play that much of a role.

There is one? Where? Last time I looked (a while ago, admittedly)
there was no denotational (or any formal) semantics for Haskell.
 - lots of stuff for fragments of Haskell-like languages or parts of Haskell, 
but not a 
full proper definitive semantics for *Haskell*, as found in the wild... 

Looking at
 http://en.wikibooks.org/wiki/Haskell/Denotational_semantics
the first footnote states
  In fact, there are no written down and complete denotational semantics of 
Haskell. This would be a tedious task void of additional insight and we happily 
embrace the folklore and common sense semantics.

However, if you have a proof-based tool used for reasoning about Haskell 
programs
in a safety-critical environment, you might just need to do this tedious task,
particularly in order to show your proof rules sound.
 - has anyone in that area done this? is it available ?

Is there a definitive Operational Semantics? Axiomatic?

PS - I love the mascot - thanks Heath !
 
 
 Greets,
 Ertugrul
 
 
 -- 
 nightmare = unsafePerformIO (getWrongWife = sex)
 http://ertes.de/
 
 
 
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe


Andrew Butterfield Tel: +353-1-896-2517 Fax: +353-1-677-2204
Lero@TCD, Head of Foundations  Methods Research Group
Director of Teaching and Learning - Undergraduate,
School of Computer Science and Statistics,
Room G.39, O'Reilly Institute, Trinity College, University of Dublin
  http://www.scss.tcd.ie/Andrew.Butterfield/



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


Re: [Haskell-cafe] How unique is Unique

2011-05-27 Thread Andrew Butterfield

On 27 May 2011, at 08:35, Emil Axelsson wrote:

 Hello!
 
 Lacking a proper blog, I've written some notes about Data.Unique here:
 
  http://community.haskell.org/~emax/darcs/MoreUnique/
 
 This describes a real problem that makes Data.Unique unsuitable for 
 implementing observable sharing.

Looking at the source for Data.Unique shows that its implemented as an Integer, 
starting at 0,
when the IO monad is started - so the values are only unique within a single 
I/O run,
and are definitely not comparable across runs...
 
 The document also proposes a solution that uses time stamps to generate 
 symbols that are more unique.
 
 Does anyone have any comments on the proposed solution? Are there any 
 alternatives available?

I haven't had time to look at that part yet 
 
 Thanks!
 
 / Emil
 
 
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe


Andrew Butterfield Tel: +353-1-896-2517 Fax: +353-1-677-2204
Foundations and Methods Research Group Director.
School of Computer Science and Statistics,
Room F.13, O'Reilly Institute, Trinity College, University of Dublin
http://www.cs.tcd.ie/Andrew.Butterfield/


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


Re: [Haskell-cafe] Status of Haskell + Mac + GUIs graphics

2011-05-18 Thread Andrew Butterfield
I have developed a GUI app using wxHaskell

I develop using GHCi - invaluable
  I can run the application once form GHCi, and then a re-run crashes, but
   - usually after a run there is enough time to re-start GHCi while I tihnk 
about what
needs fixing next
  - usually I can still run tests and queries from GHCi afterwards...

This works because I develop in Windows using GHC 6.10.4 wxHaskell 0.11.1.2
 - I haven't upgraded because I believe the GHCi behaviour worsens on later 
versions of GHC
  (I'm open to correction on this)

- a student of mine has been able to build it on linux using the latest 
versions of everything
 - I had to revise some of my code simply because later GHC versions introduced 
new keywords

So - to summarise 
  If you are happy to develop using 6.10.4, on Windows then wxHaskell is 
workable with GHCi
  It seems to then build ok on Linux

 Alas - I have yet to be able to build it on Mac OS X (Snow Leopard)


The app ? - see http://www.scss.tcd.ie/Andrew.Butterfield/Saoithin/


On 18 May 2011, at 00:24, Conal Elliott wrote:

 I still haven't found any way to do GUIs or interactive graphics in Haskell 
 on a Mac that isn't plagued one or more of the following serious problems:
 
 * Incompatible with ghci, e.g., fails to make a window frame or kills the 
 process the second time one opens a top-level window,
 * Goes through the X server, and so doesn't look or act like a Mac app,
 * Doesn't support OpenGL.
 
 A year or two ago, I put my Haskell GUI  graphics work on hold while waiting 
  hoping for a functioning pathway to open. So far I haven't heard of one.
 
 If anyone has found a solution, I'd love to hear!
 
   - Conal
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe


Andrew Butterfield Tel: +353-1-896-2517 Fax: +353-1-677-2204
Foundations and Methods Research Group Director.
School of Computer Science and Statistics,
Room F.13, O'Reilly Institute, Trinity College, University of Dublin
http://www.cs.tcd.ie/Andrew.Butterfield/


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


Re: [Haskell-cafe] Those damned parentheses

2011-05-10 Thread Andrew Butterfield

On 10 May 2011, at 08:30, Yitzchak Gale wrote:

 
 If I were to describe to someone in words what this
 function does, I would say something like: Apply Main.id,
 turn it into a string, tack a message onto the end, and
 print it. So why not write it that way in Haskell?

Why not indeed ?

(--) = flip (.)

f = Main.id -- show -- (++  = message received) -- putStrLn

;-)


 
 One of the nicest features of Haskell is that the
 combinator approach is often so natural.

:-) :-)

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


Andrew Butterfield Tel: +353-1-896-2517 Fax: +353-1-677-2204
Foundations and Methods Research Group Director.
School of Computer Science and Statistics,
Room F.13, O'Reilly Institute, Trinity College, University of Dublin
http://www.cs.tcd.ie/Andrew.Butterfield/


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


Re: [Haskell-cafe] Haskell IDE

2011-03-03 Thread Andrew Butterfield

On 3 Mar 2011, at 07:05, Hauschild, Klaus (EXT) wrote:

 Hi Haskellers,
  
 whats your Haskell IDE of choise? Currently I use leksah. Is the EclipseFP 
 Plugin for Eclipse a real alternative?

WinEdt*/MikTex/GHCi

do leksah/EclipseFP support literate haskell programming (mix of .tex and .lhs 
files) ?


* not to be confused with WinEdit !

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


Andrew Butterfield Tel: +353-1-896-2517 Fax: +353-1-677-2204
Foundations and Methods Research Group Director.
School of Computer Science and Statistics,
Room F.13, O'Reilly Institute, Trinity College, University of Dublin
http://www.cs.tcd.ie/Andrew.Butterfield/


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


Re: [Haskell-cafe] I'm still having challenges to get a Haskell GUI to work under Windows 7

2010-10-08 Thread Andrew Butterfield

On 07/10/2010 19:58, cas...@istar.ca wrote:

I'm still having challenges to get a Haskell GUI to work under Windows
7; even after various instructions on the web.

e.g. Haskell Platform 2010.2.0.0, wxWidgets-2.9.1, wxHaskell 0.12.1.6


I have seen wxHaskell work on WIndows 7, using the same configuration 
that works for me on Win XP and Vista (small test program)


namely GHC 6.10.4   wxHaskell 0.11.1.2 - uses wxWidgets-2.8.something

Installed from binaries.

To distribute a useable binary you send around a .exe plus the wxhaskell 
dll.


See http://www.scss.tcd.ie/Andrew.Butterfield/Saoithin/#bin


I hope to try this program out on Win 7 later today - I'll let you know 
how I got on...


So unless you really need all the extra goodies of platform 2010,
the current fix is to work back to ghc 6.10.4


Similar challenges with GTK+ and gtk2hs.



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



--
---
Andrew Butterfield Tel: +353-1-896-2517 Fax: +353-1-677-2204
Foundations and Methods Research Group Director. School of
Computer Science and Statistics, Room F.13, O'Reilly Institute,
Trinity College, University of Dublin, Rep. of Ireland.

  https://www.scss.tcd.ie/Andrew.Butterfield/
---
O ascii ribbon campaign - stop html mail - www.asciiribbon.org
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] I'm still having challenges to get a Haskell GUI to work under Windows 7

2010-10-08 Thread Andrew Butterfield
The windows binaries built using GHC 10.6.4 and wxHaskell 0.11.1.2 on either 
Win XP or Win 7
work on WIn 7 just fine, except for the font dialog box, which does nothing. 
This dialog box was a bit flaky on WInXP in any case.


I installed 10.6.4 above on WIndows 7 using the binary installer, even though 
the web-page did not mention WIndows 7 - it seems to work just fine.


On 8 Oct 2010, at 09:07, Andrew Butterfield wrote:

 
 I hope to try this program out on Win 7 later today - I'll let you know how I 
 got on...
 

Andrew Butterfield
andrew.butterfi...@cs.tcd.ie



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


Re: [Haskell-cafe] I still cannot seem to get a GUI working under Windows.

2010-09-30 Thread Andrew Butterfield

On 29 Sep 2010, at 20:34, Steve Schafer wrote:

 
 This is an attitude that just doesn't fly in the Windows world. Which is
 unfortunate, because the Windows market is HUGE compared to OS X, and
 STUNNINGLY HUGE compared to everything else.
 
 The fix isn't going to be to find a developer who's willing to do the
 work to make Haskell+GUI more seamless under Windows. The fix is for the
 Haskell community--as a whole--to wake up and realize what the wxWidgets
 folks did a while ago: Hey, you know what? This GUI stuff is
 _important_ if we want people to pay any attention to the software that
 we write!

This is why, when I developed my theorem prover, I put GUI aspects top of the 
list

I chose wxHaskell because I wanted portability

Ironically, given the thrust of this thread, I got it working without too much 
difficulty on Windows

GHC 10.6.4, latest binaries for wxHaskell - easy to install and get working

I gather several of my students have successfully done Linux builds of same

I switched over recently  to Mac OS X (10.6), and (more irony) am having real 
difficulties
getting it to work - installing wxHaskell is a real bear on this platform


The GUI theorem prover - see http://www.scss.tcd.ie/Andrew.Butterfield/Saoithin/

(I was going to announce this project to the Haskell Community real soon now, 
so I guess this is as good a time as any .)


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

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


Re: [Haskell-cafe] I still cannot seem to get a GUI working under Windows.

2010-09-30 Thread Andrew Butterfield

On 30 Sep 2010, at 12:02, Serguey Zefirov wrote:

 2010/9/30 Andrew Coppin andrewcop...@btinternet.com:
 And even then, your
 developed application will only run on Windows boxes that have GTK+
 installed (i.e., none of them).
 
 You can copy GTK+ DLLs with application.

Works fine with wxHaskell as well 
 
 It works very well.
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe

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


Re: [Haskell-cafe] RE: Haskell as a first language?

2009-07-14 Thread Andrew Butterfield

Simon Peyton-Jones wrote:

Haskell is a great language!  Check out haskell.org.   I'm ccing the Haskell 
Cafe which is read by many people better qualified to answer your question than 
me.   (Since I've been working on Haskell for many years, I am not well 
qualified to say how it seems to a beginner.)

S

| -Original Message-
| From: Charles Turner [mailto:charlie.h.tur...@googlemail.com]
| Sent: 11 July 2009 22:52
| To: Simon Peyton-Jones
| Subject: Haskell as a first language?
| 
| I'll make this short! Do you think Haskell is a good language to start

| with? I am brand new to programming and have been using Scheme, some of
| my peers suggest I should use Haskell. It seems professional to me.
| Has features that a beginner should not worry about. What would you
| suggest. (I'm not worried about bias)
  
The biggest probelm with full Haskell for beginners is that many type 
error messages require

some familiarity with the class system, which is not a beginner topic..

However, a good starting point perhaps is Helium - a stripped down 
version of Haskell
designed for teaching, with special care gvien to producing useful 
helpful error messages...


http://www.cs.uu.nl/wiki/Helium

Then full Haskell could be introduced in semester 2/ year2 / whatever 
timeline suits


(Anything is better than Java.. sigh ;-)
| 
| Thank you very much for your time.
| 
| Charles Turner.


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



--

Andrew Butterfield Tel: +353-1-896-2517 Fax: +353-1-677-2204
Foundations and Methods Research Group Director.
School of Computer Science and Statistics,
Room F.13, O'Reilly Institute, Trinity College, University of Dublin
   http://www.cs.tcd.ie/Andrew.Butterfield/


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


Re: [Haskell-cafe] Timing pure functions?

2009-05-27 Thread Andrew Butterfield

Magnus Therning wrote:

  timeIt times ioa = let
  timeOnce = do
  t1 - getCPUTime
  a - ioa
  t2 - getCPUTime
  let t = fromIntegral (t2-t1) * 1e-12
  return t
  in sequence $ take times $ repeat timeOnce

  main = do
  fh - openBinaryFile /dev/urandom ReadMode
  d - liftM BS.unpack $ BS.hGet fh 10
  t - timeIt 10 $ return $! B64.encode d
  print t


I suspect that it all comes from `B64.encode d` being pure, hence the
encoding happens only once.  Now I _really_ want the encoding to
happen 10 times, is there some easy way to achieve this?

  
A quick answer - not a lot of thought - pass function *and* argument 
separately into timeIt ?


 timeIt times ioaf ioaarg
    a - ioaf ioaarg

As it stands you pass the thunk (B64.encode d) in so it only gets 
evaluated once
If you pass the function and argument in then a new thunk is built each 
time around

(unless the optimiser nabbles it...)

/M

[1]: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/timeit
[2]:
  



--

Andrew Butterfield Tel: +353-1-896-2517 Fax: +353-1-677-2204
Foundations and Methods Research Group Director.
School of Computer Science and Statistics,
Room F.13, O'Reilly Institute, Trinity College, University of Dublin
   http://www.cs.tcd.ie/Andrew.Butterfield/


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


Re: [Haskell-cafe] Re: ANNOUNCE: WinGhci, a GUI for GHCI on Windows

2009-03-23 Thread Andrew Butterfield

Benjamin L.Russell wrote:

This is wonderful--just what I was waiting for!  The application looks
beautiful, and I'm very happy that GHCi now has a matching GUI
application along the lines of WinHugs.
  

Indeed - me too !

It would be even better if you could provide some
installation/uninstallation information.  I unzipped the contents of
WinGhci-1.0-bin.zip into the C:\Documents and Settings\username\My
Documents\ folder, but there was no README file.
  
And version information - I tried it with GHC 6.4 and it died (Not 
Responding)


What version of GHCi does it require?

And no, I won't upgrade GHC just yet (this is the latest GHC/wxHaskell 
combo that works for me with GHCi...)


  



--

Andrew Butterfield Tel: +353-1-896-2517 Fax: +353-1-677-2204
Foundations and Methods Research Group Director.
School of Computer Science and Statistics,
Room F.13, O'Reilly Institute, Trinity College, University of Dublin
   http://www.cs.tcd.ie/Andrew.Butterfield/


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


Re: [Haskell-cafe] type metaphysics

2009-02-02 Thread Andrew Butterfield

Martijn van Steenbergen wrote:



To my naive mind this sounds
suspiciously like the set of all sets, so it's too big to be a set.


Here you're probably thinking about the distinction between countable 
and uncountable sets. See also:


http://en.wikipedia.org/wiki/Countable_set

No - it's even bigger than those !

He is thinking of proper classes, not sets.

http://en.wikipedia.org/wiki/Class_(set_theory)

--

Andrew Butterfield Tel: +353-1-896-2517 Fax: +353-1-677-2204
Foundations and Methods Research Group Director.
School of Computer Science and Statistics,
Room F.13, O'Reilly Institute, Trinity College, University of Dublin
   http://www.cs.tcd.ie/Andrew.Butterfield/


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


Re: [Haskell-cafe] Re: Password hashing

2008-10-29 Thread Andrew Butterfield



someone asked:

What can be used for generating a random salt? Is System.Random
secure enough?
  

Achim Schneider wrote:

...or by pinging a random host and taking the time difference, checking
the current cpu temperature and fan speed, counting how many times
your process gets suspended in a certain amount of time, taking a
picture of a lava lamp and hashing it, booting windows, not doing
anything, and measure the time it takes to crash, hashing a snapshot
of the slashdot frontpage, and, last, but not least, measuring the
amount of spam per second currently swooshing into your mail account.

  


or http://www.random.org/ perhaps ?

--

Andrew Butterfield Tel: +353-1-896-2517 Fax: +353-1-677-2204
Foundations and Methods Research Group Director.
School of Computer Science and Statistics,
Room F.13, O'Reilly Institute, Trinity College, University of Dublin
   http://www.cs.tcd.ie/Andrew.Butterfield/


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


Re: [Haskell-cafe] I/O without monads, using an event loop

2008-05-30 Thread Andrew Butterfield

Robin Green wrote:

I have been thinking about to what extent you could cleanly do I/O
without explicit use of the I/O monad, and without uniqueness types
(which are the main alternative to monads in pure functional
programming, and are used in the Concurrent Clean programming language).

Suppose you have a main event handler function, like this:

eventMain :: (Event, SystemState AppState) - (Command, SystemState
AppState)

This function could be called over and over in an event loop, until an
EndProgram command was received, and the event loop would itself do all
the actual I/O (the SystemStates are only in-memory representations of
some part of the system state, plus the application's own state). Things
like disk I/O could be done with commands which generate events when
complete. Interprocess communication could be done in the same way.

Then eventMain, and everything called by it, would be
referentially-transparent, and yet non-monadic. You could of course
build higher-level stuff on top of that.
  
Given the above, without uniqueness typing, and because there is clearly 
no monad,

I could write

breakMain
:: (Event,Event,SystemState AppState)
 - ((Command,SystemState AppState),(Command,SystemState AppState))
breakMain (e1,e2,sys) = ( eventMain (e1,sys) , eventMain (e2,sys) )

Now what happens? Do we get two copies of SystemState ?

Simpler still, I can write  (sys,eventMain e sys) -- what happens here?
I have references to both before- and after- state.

It is this probelm with copying the un-copiable (external I/O state),
that requires pure functional languages to outlaw such programs,
either via uniqueness typing, or via a monad interface that completely
hides any direct reference to the underlying state and which
then sequences the application of state transformers.
  



--

Andrew Butterfield Tel: +353-1-896-2517 Fax: +353-1-677-2204
Foundations and Methods Research Group Director.
School of Computer Science and Statistics,
Room F.13, O'Reilly Institute, Trinity College, University of Dublin
   http://www.cs.tcd.ie/Andrew.Butterfield/


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


Re: [Haskell-cafe] Wumpus World

2008-03-28 Thread Andrew Butterfield

Benjamin L. Russell wrote:



Not all students and researchers can afford a Personal
License.  Can you recommend an alternative, fast
Prolog development system under a free licensing
agreement, such as GPL/GLPL?
  


For Mac users, https://www.cs.tcd.ie/open-prolog/ might be worth a look
  


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


Re: [Haskell-cafe] Mutable arrays

2008-02-15 Thread Andrew Butterfield

Stefan O'Rear wrote:

On Wed, Feb 06, 2008 at 08:57:43PM +, Andrew Butterfield wrote:
  

In Clean, we not only have explicit access to the world, but
we can partition it. Simplifying somewhat, we could open up
pairs of file-handle (f1.in,f1.out), (f2.in,f2,out) ... (fn.in,fn.out),
which does have to be done sequentially, since each file opening modifies 
the (global) filesystem. However, once this is done,

we could, in principle, execute the fn in any order,
and indeed in such a way that the implementation could choose to
do them in parallel - this potential for (admittedly limited)
deterministic parallel execution of I/O actions is possible with
uniqueness types, but not epxressible in the monadic world as
currently formulated.



What if f1.out is a symlink to f2.out?  I don't think Clean satisfies
the evaluation order independance that is so treasured here.
  

Sorry for lateness in getting back - it's been one of those fortnights..

The case you mention won't arise simply because during the process
of opening these file-handles (which cannot be done in parallel, because 
they all
modify the filesystem), the write conflict will be detected, and the 
opening of the

second one will fail.

Once the file-handle pairs are all opened we have a guarantee that all
writes are to distinct files.


--

Andrew Butterfield Tel: +353-1-896-2517 Fax: +353-1-677-2204
Foundations and Methods Research Group Director.
Course Director, B.A. (Mod.) in CS and ICT degrees, Year 4.
Department of Computer Science, Room F.13, O'Reilly Institute,
Trinity College, University of Dublin, Ireland.
   http://www.cs.tcd.ie/Andrew.Butterfield/


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


Re: [Haskell-cafe] Re: A question about monad laws

2008-02-11 Thread Andrew Butterfield

Andrew Butterfield wrote:

let m denote the list monad (hypothetically). Let's instantiate:

return :: x - [x]
return x = [x,x]

(=) :: [x] - (x - [y]) - [y]
xs = f   =  concat ((map f) xs)

Let g n = [show n]

Here  (return 1 = g ) [1,2,3] = [1,1,1,1,1,1]
but  g[1,2,3] = [1,2,3],
thus violating the first monad law   | return 
http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:return 
a = 
http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:gt;gt;= 
f  =  f a


I messed this up - I was trying for the simplest example I could get ! 
Apologies.


Start over:

Program 

module BadMonad where
import Monad

newtype MyList t = MyList [t]

instance Show t = Show (MyList t) where
 show (MyList xs) = show xs

unmylist (MyList xs) = xs

myconcat xs = MyList (concat (map unmylist xs))

instance Monad MyList  where
 return x  =  MyList [x,x]
 (MyList xs) = f  =  myconcat ((map f) xs)

i2s :: Int - MyList Char
i2s x = MyList (show x)

m = i2s 9

Hugs transcript 

BadMonad m
9 :: MyList Char
BadMonad m = return
99 :: MyList Char

We violate the second law (Right Identity, m = m = return )


--

Andrew Butterfield Tel: +353-1-896-2517 Fax: +353-1-677-2204
Foundations and Methods Research Group Director.
Course Director, B.A. (Mod.) in CS and ICT degrees, Year 4.
Department of Computer Science, Room F.13, O'Reilly Institute,
Trinity College, University of Dublin, Ireland.
   http://www.cs.tcd.ie/Andrew.Butterfield/


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


Re: [Haskell-cafe] Re: A question about monad laws

2008-02-11 Thread Andrew Butterfield

apfelmus wrote:

Deokjae Lee wrote:

Tutorials about monad mention the monad axioms or monad laws. The
tutorial All About Monads says that It is up to the programmer to
ensure that any Monad instance he creates satisfies the monad laws.

The following is one of the laws.

(x = f) = g == x = (\v - f v = g)

However, this seems to me a kind of mathematical identity. If it is
mathematical identity, a programmer need not care about this law to
implement a monad. Can anyone give me an example implementation of
monad that violate this law ?


I will be mean by asking the following counter question:

  x + (y + z) = (x + y) + z

is a mathematical identity. If it is a mathematical identity, a 
programmer need not care about this law to implement addition + . Can 
anyone give me an example implementation of addition that violates 
this law?

Hugs 1.0 + (2.5e-15 + 2.5e-15)
1.01 :: Double
Hugs (1.0 + 2.5e-15) + 2.5e-15
1.0 :: Double

Hugs, on Pentium 4 machine  running Windows XP SP2 (all of which is 
largely irrelevant!)


This is precisely Jerzy's point - you can have many mathematical laws as 
you like but there is no guarantee

that a programming languages implementation will  satisfy them.

The above example is due to rounding errors and arises because the 
Double type in Haskell (or C, C++, whatever)
is a finite (rational) approximation to real numbers which are infinite 
(platonic) entities.


Associativity of addition applies for platonic reals, but not their 
widely used IEEE-standard approximate implementation

on standard hardware.

For monads, the situation is slightly different.
Haskell describes the signature of the monadic operators

return :: x - m x
(=) :: m a - (a - m b) - m b

but cannot restrict how you actually instantiate these.
It admonishes you by stating that you should obey the relevant laws, but 
cannot enforce this.


(of course, technically if you implement a dodgy monad, its not really a 
monad at all, but something
different with operators with the same name and types - also technically 
values of type Double are

not real numbers, (or true rationals either !)

let m denote the list monad (hypothetically). Let's instantiate:

return :: x - [x]
return x = [x,x]

(=) :: [x] - (x - [y]) - [y]
xs = f   =  concat ((map f) xs)

Let g n = [show n]

Here  (return 1 = g ) [1,2,3] = [1,1,1,1,1,1]
but  g[1,2,3] = [1,2,3],
thus violating the first monad law   | return 
http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:return 
a = 
http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:gt;gt;= 
f  =  f a


|


Andrew Butterfield Tel: +353-1-896-2517 Fax: +353-1-677-2204
Foundations and Methods Research Group Director.
Course Director, B.A. (Mod.) in CS and ICT degrees, Year 4.
Department of Computer Science, Room F.13, O'Reilly Institute,
Trinity College, University of Dublin, Ireland.
   http://www.cs.tcd.ie/Andrew.Butterfield/


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


Re: [Haskell-cafe] Mutable arrays

2008-02-06 Thread Andrew Butterfield
.in,f2,out) ... (fn.in,fn.out),
which does have to be done sequentially, since each file opening 
modifies the (global) filesystem. However, once this is done,

we could, in principle, execute the fn in any order,
and indeed in such a way that the implementation could choose to
do them in parallel - this potential for (admittedly limited)
deterministic parallel execution of I/O actions is possible with
uniqueness types, but not epxressible in the monadic world as
currently formulated.

(3) Shameless plug : a semantics for I/O that covers both Clean and 
Haskell and which scopes out the deterministic parallelism alluded to

above was described in

Malcolm Dowse, Andrew Butterfield: Modelling deterministic concurrent 
I/O. ICFP 2006: 148-159  http://doi.acm.org/10.1145/1159803.1159823






--

Andrew Butterfield Tel: +353-1-896-2517 Fax: +353-1-677-2204
Foundations and Methods Research Group Director.
Department of Computer Science, Room F.13, O'Reilly Institute,
Trinity College, University of Dublin, Ireland.
http://www.cs.tcd.ie/Andrew.Butterfield/

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


Re: [Haskell-cafe] Mutable arrays

2008-02-06 Thread Andrew Butterfield

Peter Verswyvelen wrote:

So you say uniqueness typing might be more general… Can one make list 
monads and all the other funky Haskell monads with Clean’s uniqueness 
typing then?


As my long post pointed out - as far IO is concerned, Clean is more 
general than Haskell (less over-sequencing).


However in a general setting, monads are very general, much more so
than Clean's I/O uniqueness types. Monads capture a fundamental pattern
of sequential side-effecting computation in a pure referentially 
transparent way - IO is just a specific instance of this.


Having said that, it's worth noting that list and maybe monads can
be introduced in Clean, but these would have nothing to do with the
I/O infrastructure in that language.



--

Andrew Butterfield Tel: +353-1-896-2517 Fax: +353-1-677-2204
Foundations and Methods Research Group Director.
Department of Computer Science, Room F.13, O'Reilly Institute,
Trinity College, University of Dublin, Ireland.
http://www.cs.tcd.ie/Andrew.Butterfield/

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


Re: [Haskell-cafe] using an external application

2007-11-02 Thread Andrew Butterfield



On 11/2/07, Petr Hoffmann [EMAIL PROTECTED] wrote:
 

import System.Cmd
main = do
  System.Cmd.system echo hello output.txt -- use the external
application to create an output file
  o1 - readFile output.txt
  System.Cmd.system echo bye output.txt -- the second call to
the external application
  o2 - readFile output.txt
  putStr o1 -- hello expected, but bye printed
  return 0

Can you please give me some hint to solve this problem?
I'm a beginning haskell developer and I'm still a bit confused
by the IO monad.



  
I'm puzzled - when I run this on GHCi (v6.4, Windows XP) I get the 
following outcome


*Mainmain
The process cannot access the file because it is being used by another 
process.

hello
*Main

This is certainly the behaviour I would expect - seeing bye being 
printed seems to me to be an error

and may even constitute a violation of referential transparency.

What implementation  of GHC are you using ?

This looks like yet another case of the lazy-I/O goblins.
  

Yes, but not quite what everyone has being addressing


--

Andrew Butterfield Tel: +353-1-896-2517 Fax: +353-1-677-2204
Foundations and Methods Research Group Director.
Course Director, B.A. (Mod.) in CS and ICT degrees, Year 4.
Department of Computer Science, Room F.13, O'Reilly Institute,
Trinity College, University of Dublin, Ireland.
   http://www.cs.tcd.ie/Andrew.Butterfield/


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


Re: [Haskell-cafe] Re: OCaml list sees abysmal Language Shootout results

2004-10-07 Thread Andrew Butterfield
At 03:08 PM 07/10/2004 +0100, MR K P SCHUPKE wrote:
I though clean was always strict, and that was the major difference
between clean and haskell (that and the fact clean is a proprietry language)
No - Clean is pure and lazy like Haskell,
- the key difference is that it uses
uniqueness types rather than monads to ensure the I/O is referentially
transparent and safe.

Keean.
___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Dr. Andrew Butterfield (http://www.cs.tcd.ie/Andrew.Butterfield/)
Course Director, B.A. (Mod.) Information  Communications Technology
Dept.of Computer Science, Trinity College, Dublin University
Tel: +353-1-608-2517, Fax: +353-1-677-2204

___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe