Re: [Haskell-cafe] Laziness question

2010-07-31 Thread Brandon S Allbery KF8NH
the first response was cagey, possibly suspecting a homework question although it seems like an odd time for it.) length not only does not look inside of the thunk, it *can't* look inside it; all it knows is that it has a list, it specifically does *not* know what that list can hold. So the only thing

Re: [Haskell-cafe] Laziness question

2010-07-31 Thread Tillmann Rendel
michael rice wrote: f x = length [head x] g x = length (tail x) Wouldn't both functions need to evaluate x to the same level, *thunk* : *thunk* to insure listhood? There is no need to insure listhood at run time, since Haskell is statically typed. Tillmann

Re: [Haskell-cafe] Laziness question

2010-07-31 Thread michael rice
Subtle stuff. Thanks, everyone, for your patience. You've been VERY helpful. Great list! Michael --- On Sat, 7/31/10, Brandon S Allbery KF8NH allb...@ece.cmu.edu wrote: From: Brandon S Allbery KF8NH allb...@ece.cmu.edu Subject: Re: [Haskell-cafe] Laziness question To: haskell-cafe@haskell.org

Re: [Haskell-cafe] Laziness question

2010-07-31 Thread wren ng thornton
suspecting a homework question although it seems like an odd time for it.) length not only does not look inside of the thunk, it *can't* look inside it; all it knows is that it has a list, it specifically does *not* know what that list can hold. So the only thing it can do is count the number

Re: [Haskell-cafe] Laziness question

2010-07-31 Thread Brandon S Allbery KF8NH
be evaluated? Exactly. (I was being cagey because the first response was cagey, possibly suspecting a homework question although it seems like an odd time for it.) length not only does not look inside of the thunk, it *can't* look inside it; all it knows is that it has a list, it specifically

Re: [Haskell-cafe] new Cabal user question -- installing to Haskell Platform on Windows network drive?

2010-07-29 Thread Peter Schmitz
I have a question about finding the Gtk2Hs demos (the demos written in Haskell). To summarize what I have done so far: I'm a new Cabal user; need to use Cabal in a Windows XP environment, where it and the Haskell Platform are located on a network drive (H:) instead of C:. (Need to be able to do

Re: [Haskell-cafe] new Cabal user question -- installing to Haskell Platform on Windows network drive?

2010-07-29 Thread Ivan Miljenovic
On 30 July 2010 13:32, Peter Schmitz ps.hask...@gmail.com wrote: I have a question about finding the Gtk2Hs demos (the demos written in Haskell). They're not there: http://osdir.com/ml/haskell-cafe@haskell.org/2010-07/msg00724.html -- Ivan Lazar Miljenovic ivan.miljeno...@gmail.com

Re: [Haskell-cafe] new Cabal user question -- installing to Haskell Platform on Windows network drive?

2010-07-28 Thread Peter Schmitz
Rogan: Again, thanks very much for your reply. My situation is that I need to be able to use Cabal (and the Haskell Platform, Gtk2Hs, etc.) at any of several PCs in a (Windows XP) LAN, each of which has access to the network drive H:. So, I am using: H:\proc\tools\Haskell Platform

Re: [Haskell-cafe] new Cabal user question -- installing to Haskell Platform on Windows network drive?

2010-07-28 Thread Duncan Coutts
On 28 July 2010 23:46, Peter Schmitz ps.hask...@gmail.com wrote: I will try experimenting with editing the config file and using that hidden option you mentioned. ** Cabal experts: If anyone knows how to do this sort of thing in a better way, I would appreciate a word. Rogan is right. You

Re: [Haskell-cafe] new Cabal user question -- installing to Haskell Platform on Windows network drive?

2010-07-28 Thread Peter Schmitz
Rogan is right. You just need to edit the cabal config file to point to locations on your other drive. I would suggest not relocating the config file itself. If you really must do so then you can use the --config-file flag or the environment variable CABAL_CONFIG. Duncan I will try

Re: [Haskell-cafe] new Cabal user question -- installing to Haskell Platform on Windows network drive?

2010-07-27 Thread Peter Schmitz
Rogan: Thanks very much. I began by downloading the latest gtk+ bundle from http://www.gtk.org/download-windows.html The instructions there said to just copy the files to any dir and add its ...\gtk\bin dir to my PATH, which I did, so that worked okay without admin privs. Given that I need to

Re: [Haskell-cafe] new Cabal user question -- installing to Haskell Platform on Windows network drive?

2010-07-27 Thread Rogan Creswick
On Tue, Jul 27, 2010 at 2:43 PM, Peter Schmitz ps.hask...@gmail.com wrote: So, by default, cabal wants to put its config and updates on C:. I looked at C:\Documents and Settings\pschmitz\Application Data\cabal\config It has various references to C:, some commented out. E.g.:

[Haskell-cafe] Typeclasses question in Real World Haskell book

2010-07-26 Thread Angel de Vicente
Hi, I'm stuck at page 151 of Real World Haskell and hoping that perhaps some of you can give me a hand here... The code that is giving me trouble is below. data JValue = JString String | JNumber Double | JBool Bool | JNull | JObject [(String,

Re: [Haskell-cafe] Typeclasses question in Real World Haskell book

2010-07-26 Thread S. Doaitse Swierstra
How about: *Main fromJValue (JBool True) :: Either JSONError Bool Right True *Main Doaitse On 26 jul 2010, at 15:16, Angel de Vicente wrote: data JValue = JString String | JNumber Double | JBool Bool | JNull | JObject [(String, JValue)]

Re: [Haskell-cafe] Typeclasses question in Real World Haskell book

2010-07-26 Thread Daniel Fischer
On Monday 26 July 2010 15:16:36, Angel de Vicente wrote: Hi, I'm stuck at page 151 of Real World Haskell and hoping that perhaps some of you can give me a hand here... The code that is giving me trouble is below. data JValue = JString String | JNumber Double |

Re: [Haskell-cafe] Typeclasses question in Real World Haskell book

2010-07-26 Thread Angel de Vicente
Hi, thanks for the answer. This is my first attempt at Typeclasses, and I think there is something deep that I don't understand... On 26/07/10 15:03, Daniel Fischer wrote: class JSON a where toJValue :: a - JValue fromJValue :: JValue - Either JSONError a instance JSON JValue

Re: [Haskell-cafe] Typeclasses question in Real World Haskell book

2010-07-26 Thread Daniel Fischer
On Monday 26 July 2010 21:03:10, Angel de Vicente wrote: Hi, thanks for the answer. This is my first attempt at Typeclasses, and I think there is something deep that I don't understand... On 26/07/10 15:03, Daniel Fischer wrote: class JSON a where toJValue :: a - JValue

[Haskell-cafe] new Cabal user question -- installing to Haskell Platform on Windows network drive?

2010-07-26 Thread Peter Schmitz
I have recently installed the Haskell Platform (for the first time) to a MS Windows network drive; e.g.: H:\aaa\bbb\Haskell Platform\2010.1.0.0\ I did so without admin privs. It has ghc-6.12.1 I need to not install to C:. I would like to install and use Gtk2Hs and Glade on the Platform also.

Re: [Haskell-cafe] Typeclasses question in Real World Haskell book

2010-07-26 Thread Angel de Vicente
] - at least, if you don't turn on some language extension(s). That is the cause of many puzzlements and problems. thanks for this, and for the detailed explanation on my previous question. I keep a frosty Canarian beer for you in the fridge for whenever we meet... :-) I think that I can now

Re: [Haskell-cafe] new Cabal user question -- installing to Haskell Platform on Windows network drive?

2010-07-26 Thread Rogan Creswick
On Mon, Jul 26, 2010 at 2:06 PM, Peter Schmitz ps.hask...@gmail.com wrote: I have recently installed the Haskell Platform (for the first time) to a MS Windows network drive; e.g.: H:\aaa\bbb\Haskell Platform\2010.1.0.0\ I did so without admin privs. It has ghc-6.12.1 I need to not

Re: [Haskell-cafe] Typeclasses question in Real World Haskell book

2010-07-26 Thread Richard O'Keefe
On Jul 27, 2010, at 1:16 AM, Angel de Vicente wrote: data JValue = JString String | JNumber Double | JBool Bool | JNull | JObject [(String, JValue)] | JArray [JValue] deriving (Eq, Ord, Show) type JSONError = String

[Haskell-cafe] Haddock question

2010-07-21 Thread S. Doaitse Swierstra
I am trying to document my parser library. In order to do so I should like to include some example output in my haddock documentation. I fail to see however how to get a block of output into the haddock part. E.g. -- | We can now run the parser @`pa`@ on input \a\, which succeeds: -- @

[Haskell-cafe] Haddock question

2010-07-21 Thread S. Doaitse Swierstra
I am trying to document my parser library. In order to do so I should like to include some example output in my haddock documentation. I fail to see however how to get a block of output into the haddock part. E.g. -- | We can now run the parser @`pa`@ on input \a\, which succeeds: -- @

Re: [Haskell-cafe] Haddock question

2010-07-21 Thread Daniel Fischer
On Wednesday 21 July 2010 16:09:37, S. Doaitse Swierstra wrote: I am trying to document my parser library. In order to do so I should like to include some example output in my haddock documentation. I fail to see however how to get a block of output into the haddock part. E.g. -- | We can

Re: [Haskell-cafe] Haddock question

2010-07-21 Thread S. Doaitse Swierstra
Unfortunately I get for input: -- | We can now run the parser @`pa`@ on input \a\, which succeeds: -- @ -- Result: \a\ -- Second line -- @ the output We can now run the parser pa on input a, which succeeds: Result: a Second line Doaitse On 21 jul 2010, at 16:17, Daniel Fischer

Re: [Haskell-cafe] Haddock question

2010-07-21 Thread Daniel Fischer
On Wednesday 21 July 2010 16:23:48, S. Doaitse Swierstra wrote: Unfortunately I get for input: -- | We can now run the parser @`pa`@ on input \a\, which succeeds: -- @ -- Result: \a\ -- Second line -- @ the output You need to separate the @'d paragraph from the rest of the comment by

Re: [Haskell-cafe] Haddock question

2010-07-21 Thread Ivan Lazar Miljenovic
S. Doaitse Swierstra doai...@cs.uu.nl writes: Unfortunately I get for input: -- | We can now run the parser @`pa`@ on input \a\, which succeeds: -- @ -- Result: \a\ -- Second line -- @ the output We can now run the parser pa on input a, which succeeds: Result: a Second line

Re: [Haskell-cafe] A question about State Monad and Monad in general

2010-07-20 Thread C K Kashyap
. Is it right to assume that magic is backed by FFI and cannot be done in pure Haskell? On Mon, Jul 19, 2010 at 1:47 PM, Ketil Malde ke...@malde.org wrote: C K Kashyap ckkash...@gmail.com writes: I looked at State Monad yesterday and this question popped into my mind. From what I

Re: [Haskell-cafe] A question about State Monad and Monad in general

2010-07-19 Thread Ketil Malde
C K Kashyap ckkash...@gmail.com writes: I looked at State Monad yesterday and this question popped into my mind. From what I gather State Monad essentially allows the use of Haskell's do notation to invisibly pass around a state. So, does the use of Monadic style fetch us more than syntactic

Re: [Haskell-cafe] A question about State Monad and Monad in general

2010-07-19 Thread C K Kashyap
Okay...I think I am beginning to understand. Is it right to assume that magic is backed by FFI and cannot be done in pure Haskell? On Mon, Jul 19, 2010 at 1:47 PM, Ketil Malde ke...@malde.org wrote: C K Kashyap ckkash...@gmail.com writes: I looked at State Monad yesterday and this question

Re: [Haskell-cafe] A question about State Monad and Monad in general

2010-07-19 Thread C K Kashyap
Haskell? On Mon, Jul 19, 2010 at 1:47 PM, Ketil Malde ke...@malde.org wrote: C K Kashyap ckkash...@gmail.com writes: I looked at State Monad yesterday and this question popped into my mind. From what I gather State Monad essentially allows the use of Haskell's do notation to invisibly pass

Re: [Haskell-cafe] A question about State Monad and Monad in general

2010-07-19 Thread Max Rabkin
On Mon, Jul 19, 2010 at 10:17 AM, Ketil Malde ke...@malde.org wrote: At it's heart, monads are just syntactic convenience, but like many other syntactic conveniences, allows you to structure your code better. Thus it's more about programmer efficiency than program efficiency. (The do notation

Re: [Haskell-cafe] A question about State Monad and Monad in general

2010-07-19 Thread aditya siram
looked at State Monad yesterday and this question popped into my mind. From what I gather State Monad essentially allows the use of Haskell's do notation to invisibly pass around a state. So, does the use of Monadic style fetch us more than syntactic convenience? At it's heart, monads

Re: [Haskell-cafe] A question about State Monad and Monad in general

2010-07-19 Thread aditya siram
...@gmail.com writes: I looked at State Monad yesterday and this question popped into my mind. From what I gather State Monad essentially allows the use of Haskell's do notation to invisibly pass around a state. So, does the use of Monadic style fetch us more than syntactic convenience

Re: [Haskell-cafe] A question about State Monad and Monad in general

2010-07-16 Thread C K Kashyap
Thanks Wren, Thanks Dave ... a quick question though could you point me to an example where I could build up my own in place modifiable data structure in Haskell without using any standard library stuff? For example, if I wanted an image representation such as this [[(Int,Int.Int)]] - basically

Re: [Haskell-cafe] A question about State Monad and Monad in general

2010-07-16 Thread Claude Heiland-Allen
Hi, On 16/07/10 07:35, C K Kashyap wrote: Haskell without using any standard library stuff? For example, if I wanted an image representation such as this [[(Int,Int.Int)]] - basically a list of lists of 3 tuples (rgb) and wanted to do in place replacement to set the pixel values, how could I

Re: [Haskell-cafe] A question about State Monad and Monad in general

2010-07-16 Thread C K Kashyap
Hi Claude, Thanks a lot for the example. Btw, is this where you are trying in-place replacement? modifyAtIndex :: (a - a) - Nat - List a - List a modifyAtIndex f i as = let ias = zip nats as g (Tuple2 j a) = case i `eq` j of False - a

[Haskell-cafe] A question about State Monad and Monad in general

2010-07-15 Thread C K Kashyap
Hi, I looked at State Monad yesterday and this question popped into my mind. From what I gather State Monad essentially allows the use of Haskell's do notation to invisibly pass around a state. So, does the use of Monadic style fetch us more than syntactic convenience? Again, if I understand

Re: [Haskell-cafe] A question about State Monad and Monad in general

2010-07-15 Thread Daniel Fischer
On Thursday 15 July 2010 18:02:47, C K Kashyap wrote: Hi, I looked at State Monad yesterday and this question popped into my mind. From what I gather State Monad essentially allows the use of Haskell's do notation to invisibly pass around a state. So, does the use of Monadic style fetch

Re: [Haskell-cafe] A question about State Monad and Monad in general

2010-07-15 Thread David Leimbach
On Thu, Jul 15, 2010 at 9:02 AM, C K Kashyap ckkash...@gmail.com wrote: Hi, I looked at State Monad yesterday and this question popped into my mind. From what I gather State Monad essentially allows the use of Haskell's do notation to invisibly pass around a state. So, does the use of Monadic

Re: [Haskell-cafe] A question about State Monad and Monad in general

2010-07-15 Thread C K Kashyap
Thanks Daniel, Better refactorability. If you're using monadic style, changing from, say, State Thing to StateT Thing OtherMonad or from StateT Thing FirstMonad to StateT Thing SecondMonad typically requires only few changes. Explicit state-passing usually requires more changes. So,

Re: [Haskell-cafe] A question about State Monad and Monad in general

2010-07-15 Thread C K Kashyap
to be done using FFI only? On Thu, Jul 15, 2010 at 10:48 PM, David Leimbach leim...@gmail.com wrote: On Thu, Jul 15, 2010 at 9:02 AM, C K Kashyap ckkash...@gmail.com wrote: Hi, I looked at State Monad yesterday and this question popped into my mind. From what I gather State Monad

Re: [Haskell-cafe] A question about State Monad and Monad in general

2010-07-15 Thread David Leimbach
computation. Dave On Thu, Jul 15, 2010 at 10:48 PM, David Leimbach leim...@gmail.comwrote: On Thu, Jul 15, 2010 at 9:02 AM, C K Kashyap ckkash...@gmail.com wrote: Hi, I looked at State Monad yesterday and this question popped into my mind. From what I gather State Monad essentially allows

Re: [Haskell-cafe] A question about State Monad and Monad in general

2010-07-15 Thread wren ng thornton
C K Kashyap wrote: Thanks Daniel, Better refactorability. If you're using monadic style, changing from, say, State Thing to StateT Thing OtherMonad or from StateT Thing FirstMonad to StateT Thing SecondMonad typically requires only few changes. Explicit state-passing usually requires more

Re: [Haskell-cafe] a very pedestrian question about maillists

2010-07-03 Thread Roman Cheplyaka
* Vasili I. Galchin vigalc...@gmail.com [2010-07-02 23:51:09-0500] Hello, Suppose I have the following fragment of a posting: Message: 3 Date: Fri, 2 Jul 2010 12:32:43 -0500 From: aditya siram aditya.si...@gmail.com Subject: Re: [Haskell-cafe] How easy is it to hire Haskell

[Haskell-cafe] a very pedestrian question about maillists

2010-07-02 Thread Vasili I. Galchin
Hello, Suppose I have the following fragment of a posting: Message: 3 Date: Fri, 2 Jul 2010 12:32:43 -0500 From: aditya siram aditya.si...@gmail.com Subject: Re: [Haskell-cafe] How easy is it to hire Haskell programmers To: Andrew Coppin andrewcop...@btinternet.com Cc:

[Haskell-cafe] Newbie question about using WinGHCi

2010-07-01 Thread Christopher Tauss
Hello - I just a day or so ago downloaded Hakell and am playing around with it, and I came upon this problem with WinGHCi: I am able to enter a multi-line do statement that works if I use brackets and semi-colon like so: Prelude :{ Prelude| let main2 = do { Prelude| putStrLn Please enter your

Re: [Haskell-cafe] Newbie question about using WinGHCi

2010-07-01 Thread Ivan Miljenovic
On 1 July 2010 16:04, Christopher Tauss ctau...@gmail.com wrote: Hello - I just a day or so ago downloaded Hakell and am playing around with it, and I came upon this problem with WinGHCi: I am able to enter a multi-line do statement that works if I use brackets and semi-colon like so:

[Haskell-cafe] functional dependencies question

2010-07-01 Thread Patrick Browne
Hi, My understanding of functional dependencies is that they can be used to ensure that one type depends on another type. For example, the type of location depends could on the type of the object at that location. Consider two models 1) The location of an aircraft landing should have location of

Re: [Haskell-cafe] functional dependencies question

2010-07-01 Thread Neil Brown
On 01/07/10 12:37, Patrick Browne wrote: Why do some cases such as 1) fail to run even if they are the only instantiation. -- 1) Compiles but does not run instance LocatedAt Int String where spatialLocation(1)=home That instance is fine. I presume the problem is that you are trying

Re: [Haskell-cafe] functional dependencies question

2010-07-01 Thread Patrick Browne
Neil, Does the following sum up the situation? The class Num has subclasses containing various numeric types and the literal 1 is a value for one or more of those types. Hence the Haskell compiler says the instance 1) is OK. But at run time, without the quantified (1:Int), the 1 could of more than

Re: [Haskell-cafe] functional dependencies question

2010-07-01 Thread Ketil Malde
Patrick Browne patrick.bro...@dit.ie writes: Why do some cases such as 1) fail to run even if they are the only instantiation. I think this is because literal numbers are polymorphic, i.e. a '1' in your source code is shorthand for 'fromIntegral 1', which is a type of Num a = a. Thus,

Re: [Haskell-cafe] functional dependencies question

2010-07-01 Thread Miguel Mitrofanov
The class Num has subclasses containing various numeric types and the literal 1 is a value for one or more of those types. Well, the problem is not with subclasses, but with types. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] functional dependencies question

2010-07-01 Thread Neil Brown
On 01/07/10 13:11, Patrick Browne wrote: Neil, Does the following sum up the situation? The class Num has subclasses containing various numeric types and the literal 1 is a value for one or more of those types. Hence the Haskell compiler says the instance 1) is OK. But at run time, without the

Re: [Haskell-cafe] design question: decision tree from Programming Collective Intelligence

2010-06-24 Thread Jason Dagit
On Mon, Jun 21, 2010 at 11:22 AM, Daniel Lyons fus...@storytotell.orgwrote: Hi, I'm having a little trouble figuring out precisely how to port the decision tree code from the book Programming Collective Intelligence. You can see the code here:

[Haskell-cafe] Question regarding deepseq (Control.DeepSeq)

2010-06-24 Thread Frank Moore
Hello Haskellers, I am new to programming in Haskell and I am having trouble understanding exactly when statements become evaluated. My goal is to try and measure how long a computation takes without having to use a show function. The code I am trying to use is below (taken in part from RWH

Re: [Haskell-cafe] Question regarding deepseq (Control.DeepSeq)

2010-06-24 Thread Ivan Miljenovic
On 25 June 2010 10:57, Frank Moore fmo...@gmail.com wrote: Hello Haskellers, I am new to programming in Haskell and I am having trouble understanding exactly when statements become evaluated.  My goal is to try and measure how long a computation takes without having to use a show function. 

Re: [Haskell-cafe] Question regarding deepseq (Control.DeepSeq)

2010-06-24 Thread Frank Moore
Thanks for the reply. My main is now: main = do let as = [1..2e7] :: [Double] start - getCurrentTime let meanAs = mean as let meanOver2 = meanAs `deepseq` meanAs / 2 end - getCurrentTime putStrLn (show (end `diffUTCTime` start)) start - getCurrentTime putStrLn (show meanOver2)

Re: [Haskell-cafe] Question regarding deepseq (Control.DeepSeq)

2010-06-24 Thread Ivan Miljenovic
On 25 June 2010 11:19, Frank Moore frankmo...@math.cornell.edu wrote: Thanks for the reply. My main is now: main = do   let as = [1..2e7] :: [Double]   start - getCurrentTime   let meanAs = mean as   let meanOver2 = meanAs `deepseq` meanAs / 2   end - getCurrentTime   putStrLn (show

Re: [Haskell-cafe] Question regarding deepseq (Control.DeepSeq)

2010-06-24 Thread Daniel Fischer
On Friday 25 June 2010 02:57:31, Frank Moore wrote: Hello Haskellers, I am new to programming in Haskell and I am having trouble understanding exactly when statements become evaluated. My goal is to try and measure how long a computation takes without having to use a show function. The

Re: [Haskell-cafe] Question regarding deepseq (Control.DeepSeq)

2010-06-24 Thread Frank Moore
Daniel, This means *when meanOver2 is evaluated*, then evaluate (mean as). Binding it in a let is lazy, so it won't be evaluated until it's needed (for printing in this case). Also note that (mean as) is a Double, so deepseq is just seq in this case (but I suppose this is just a boiled down

Re: [Haskell-cafe] design question: decision tree from Programming Collective Intelligence

2010-06-22 Thread Stephen Tetley
Hello Maybe permutation trees are a viable starting point? See the paper Parsing Permutation Phrases which appears to be on CiteSeer. Some slides are also here - the data type definitions and Functor instance for permutation trees are on page 18 (pdf index page 19):

[Haskell-cafe] design question: decision tree from Programming Collective Intelligence

2010-06-21 Thread Daniel Lyons
Hi, I'm having a little trouble figuring out precisely how to port the decision tree code from the book Programming Collective Intelligence. You can see the code here: http://code.google.com/p/memothing/source/browse/trunk/PCI/ch7/treepredict.py?r=29 The design issue is that this code depends

[Haskell-cafe] Tricks with GMap -- question about conflicts w/ indexed type families

2010-06-08 Thread oleg
) -- Now we wish to define optimized instances of GMapKey for -- pairs of items that fit within a word. -- The following answers Ryan Newton's question -- Define our own product type, to avoid overlapping instances with the -- general GMapKey for pairs -- It's a newtype: it has no run-time overhead

Re: [Haskell-cafe] A question on existential types and Church encoding

2010-06-07 Thread Ryan Ingram
question: Is this type too general? Are there functions which are semantically non-boolean which fit in that type Actually, this type is *less* general, in that it has less members. Consider, what boolean is represented by this? q :: CB Int q = (+) Whereas the (forall a. a - a - a) must work

[Haskell-cafe] Tricks with GMap -- question about conflicts w/ indexed type families

2010-06-04 Thread Ryan Newton
GMaps -- families of map implementations indexed by the key type -- are an example on the wiki:   http://www.haskell.org/haskellwiki/GHC/Type_families I've been using something like this myself.  It sure would be nice to have a fully developed version on Hackage, and I may try to submit this

Re: [Haskell-cafe] design question/font metrics

2010-06-03 Thread Christopher Done
Maybe you could check out the FTGL package for inspiration on using the freetype as a conventional C library. I was going to try to write a Hackage package but realised I know nothing about typography and had to start reading the intro. on Freetype's homepage (which is pretty good, actually).

[Haskell-cafe] design question/font metrics

2010-06-01 Thread Gery Debongnie
. Basically, I would like some function like this : stringWidth :: Font - String - Double charWidth :: Font - Char - Double which take some appropriate font type, string or char, and gives me a width (also height) in some given unit. I'd like it to take into account appropriate kerning. Question 1

Re: [Haskell-cafe] design question/font metrics

2010-06-01 Thread Anthony Cowley
On Tue, Jun 1, 2010 at 10:30 AM, Gery Debongnie gery.debong...@gmail.com wrote: 3. Perform a reading of the font metrics file in the main program, put the results into some FontMetrics object, and give that to stringWidth :: FontMetrics - Font - String - Double.  Pros : allow me to avoid

Re: [Haskell-cafe] design question/font metrics

2010-06-01 Thread Stephen Tetley
Hi Gery There probably isn't a library to help - I've looked at extracting TrueType font metrics myself but abandoned it - TrueType fonts have a very complicated file format, and the spec is inadequate to code an implementation. TeX font metrics are probably simpler but obviously tied to TeX.

Re: [Haskell-cafe] design question/font metrics

2010-06-01 Thread Brandon S. Allbery KF8NH
On Jun 1, 2010, at 10:53 , Stephen Tetley wrote: There probably isn't a library to help - I've looked at extracting TrueType font metrics myself but abandoned it - TrueType fonts have a very complicated file format, and the spec is inadequate to code an The saner way to do this is to write a

Re: [Haskell-cafe] design question/font metrics

2010-06-01 Thread Stephen Tetley
Hi Brandon Even that's not simple - freetype is essentially a framework for writing font processors rather than a conventional C library[*]. Saner perhaps is to write a C program using freetype to do the exact job you have in mind, then bind to your C program. Best wishes Stephen [*} Probably

Re: [Haskell-cafe] A question on existential types and Church encoding

2010-06-01 Thread Cory Knapp
, the parameter 'a' is misleading. It has no connection to the 'a's on the right of the equals sign. You might as well write: type CB = forall a. a - a - a Ah! That makes sense. Which raises a new question: Is this type too general? Are there functiosn which are semantically non-boolean which fit

Re: [Haskell-cafe] A question on existential types and Church encoding

2010-06-01 Thread Jason Dagit
On Tue, Jun 1, 2010 at 12:40 PM, Cory Knapp cory.m.kn...@gmail.com wrote: Thanks! That was exactly the sort of response I was looking for. This explains why you need to double up for your current definitions. To choose between two booleans (which will in turn allow you to choose between

Re: [Haskell-cafe] A question on existential types and Church encoding

2010-06-01 Thread C. McCann
question: Is this type too general? Are there functiosn which are semantically non-boolean which fit in that type, and would this still be the case with your other suggestion (i.e. cand p q = p (q t f) f )? Because the type is universally quantified, any function with that signature can only

Re: [Haskell-cafe] A question on existential types and Church encoding

2010-06-01 Thread Dan Doel
in question, but I think it just tends to confuse people who are new to this, especially since holding a universal inside a datatype looks like: data U = C (forall a. ...) and removing the constructors to attempt to make it a type alias makes them look identical: type T = forall a. ... type U

Re: [Haskell-cafe] A question on existential types and Church encoding

2010-06-01 Thread Daniel Fischer
On Tuesday 01 June 2010 23:21:35, Dan Doel wrote: I think SPJ is on record as saying it would add a lot of complexity to the current GHC type system, and I'm inclined to believe him. In matters concerning the GHC type system, that's a fairly natural stance, I think.

Re: [Haskell-cafe] A question on existential types and Church encoding

2010-05-30 Thread Jason Dagit
On Sat, May 29, 2010 at 9:28 PM, Cory Knapp cory.m.kn...@gmail.com wrote: Hello, A professor of mine was recently playing around during a lecture with Church booleans (I.e., true = \x y - x; false = \x y - y) in Scala and OCaml. I missed what he did, so I reworked it in Haskell and got this:

Re: [Haskell-cafe] A question on existential types and Church encoding

2010-05-30 Thread wren ng thornton
Jason Dagit wrote: In Church's λ-calc the types are ignored, Not so. Church-style lambda calculus is the one where types matter; Curry-style is the one that ignores types and evaluates as if it were the untyped lambda calculus. Church encodings are based on the untyped LC rather than

Re: [Haskell-cafe] A question on existential types and Church encoding

2010-05-30 Thread Dan Doel
On Sunday 30 May 2010 12:28:36 am Cory Knapp wrote: type CB a = a - a - a ct :: CB aC ct x y = x cf :: CB a cf x y = y cand :: CB (CB a) - CB a - CB a cand p q = p q cf cor :: CB (CB a) - CB a - CB a cor p q = p ct q The reason these types are required is that the 'a' in your

Re: [Haskell-cafe] A question on existential types and Church encoding

2010-05-30 Thread Jason Dagit
On Sun, May 30, 2010 at 4:08 AM, wren ng thornton w...@freegeek.org wrote: Jason Dagit wrote: In Church's λ-calc the types are ignored, Not so. Church-style lambda calculus is the one where types matter; Curry-style is the one that ignores types and evaluates as if it were the untyped

[Haskell-cafe] A question on existential types and Church encoding

2010-05-29 Thread Cory Knapp
Hello, A professor of mine was recently playing around during a lecture with Church booleans (I.e., true = \x y - x; false = \x y - y) in Scala and OCaml. I missed what he did, so I reworked it in Haskell and got this: type CB a = a - a - a ct :: CB aC ct x y = x cf :: CB a cf x y = y cand ::

Re: [Haskell-cafe] MultiParamClasses question

2010-05-26 Thread Eugeny N Dzhurinsky
On Tue, May 25, 2010 at 10:46:47PM +0100, Stephen Tetley wrote: Hi Eugene You can store different things in a Map by collecting them with a simple 'sum' type: Hello, Stephen! The records to be stored into a Map are not related to each other. So wrapping them into another type is not very

[Haskell-cafe] MultiParamClasses question

2010-05-25 Thread Eugeny N Dzhurinsky
Hello, all! I'm trying to create set of polymorphic functions for working with custom containers. I decided to try out typeclass and define generic function, which uses the methods from the typeclass. The quick and naive solution is listed below:

Re: [Haskell-cafe] MultiParamClasses question

2010-05-25 Thread Stephen Tetley
Hi Eugeny Its not that GHC thinks you're doing something weird, but that there is no relation between the type parameters in the Storage class. You could use either functional dependencies or type families to introduce a relation / relations, but personally I would look at doing something simpler

Re: [Haskell-cafe] MultiParamClasses question

2010-05-25 Thread Henning Thielemann
On Tue, 25 May 2010, Eugeny N Dzhurinsky wrote: I'm trying to create set of polymorphic functions for working with custom containers. I decided to try out typeclass and define generic function, which uses the methods from the typeclass. The quick and naive solution is listed below: There are

Re: [Haskell-cafe] MultiParamClasses question

2010-05-25 Thread Daniel Fischer
On Tuesday 25 May 2010 20:51:06, Eugeny N Dzhurinsky wrote: Hello, all! I'm trying to create set of polymorphic functions for working with custom containers. I decided to try out typeclass and define generic function, which uses the methods from the typeclass. The quick and naive solution is

Re: [Haskell-cafe] MultiParamClasses question

2010-05-25 Thread Eugeny N Dzhurinsky
On Tue, May 25, 2010 at 07:59:24PM +0100, Stephen Tetley wrote: Hi Eugeny Its not that GHC thinks you're doing something weird, but that there is no relation between the type parameters in the Storage class. You could use either functional dependencies or type families to introduce a

Re: [Haskell-cafe] MultiParamClasses question

2010-05-25 Thread Stephen Tetley
Hi Eugene You can store different things in a Map by collecting them with a simple 'sum' type: import qualified Data.Map as Map type DateTime = String-- just String for now.. type URL = String type UniqueID = String Here's the sum type: data LogData = LastLogin DateTime

Re: [Haskell-cafe] Re: Proof question -- (==) over Bool

2010-05-24 Thread Alexander Solla
On May 23, 2010, at 2:53 AM, Lennart Augustsson wrote: BTW, the id function works fine on bottom, both from a semantic and implementation point of view. Yes, but only because it doesn't work at all. Consider that calling id undefined requires evaluating undefined before you can call id.

[Haskell-cafe] Re: Proof question -- (==) over Bool

2010-05-24 Thread Jon Fairbairn
Alexander Solla a...@2piix.com writes: On May 23, 2010, at 1:35 AM, Jon Fairbairn wrote: It seems to me relevant here, because one of the uses to which one might put the symmetry rule is to replace an expression “e1 == e2” with “e2 == e1”, which can turn a programme that terminates into a

Re: [Haskell-cafe] Re: Proof question -- (==) over Bool

2010-05-24 Thread Lennart Augustsson
That's totally false. You don't evaluate 'undefined' before calling 'id'. (Or if you, it's because you've made a transformation that is valid because 'id' is strict.) On Mon, May 24, 2010 at 9:05 AM, Alexander Solla a...@2piix.com wrote: Yes, but only because it doesn't work at all.  Consider

Re: [Haskell-cafe] Re: Proof question -- (==) over Bool

2010-05-24 Thread Jonas Almström Duregård
Consider that calling id undefined requires evaluating undefined before you can call id. The program will crash before you ever call id. Of course, the identity function should have produced a value that crashed in exactly the same way. But we never got there. In which sense does id need

Re: [Haskell-cafe] Re: Proof question -- (==) over Bool

2010-05-24 Thread Daniel Fischer
On Monday 24 May 2010 15:48:14, Jonas Almström Duregård wrote: Consider that calling id undefined requires evaluating undefined before you can call id. The program will crash before you ever call id. Of course, the identity function should have produced a value that crashed in

[Haskell-cafe] Re: Proof question -- (==) over Bool

2010-05-23 Thread Jon Fairbairn
Alexander Solla a...@2piix.com writes: On May 22, 2010, at 1:32 AM, Jon Fairbairn wrote: Since Bool is a type, and all Haskell types include ⊥, you need to add conditions in your proofs to exclude it. Not really. Bottom isn't a value, so much as an expression for computations that don't

Re: [Haskell-cafe] Re: Proof question -- (==) over Bool

2010-05-23 Thread Alexander Solla
On May 23, 2010, at 1:35 AM, Jon Fairbairn wrote: It seems to me relevant here, because one of the uses to which one might put the symmetry rule is to replace an expression “e1 == e2” with “e2 == e1”, which can turn a programme that terminates into a programme that does not. I don't see how

Re: [Haskell-cafe] Re: Proof question -- (==) over Bool

2010-05-23 Thread Lennart Augustsson
For Bool, I'm not sure, but for, e.g., () it's certainly true. Take this definition of == () == _ = True Using case analysis of just the constructors, ignoring the value bottom, you can easily prove symmetry. But '() == undefined' terminates, whereas 'undefined == ()' does not. Ignore bottom

[Haskell-cafe] Re: Proof question -- (==) over Bool

2010-05-22 Thread Maciej Piechotka
On Sat, 2010-05-22 at 00:15 +, R J wrote: I'm trying to prove that (==) is reflexive, symmetric, and transitive over the Bools, given this definition: (==) :: Bool - Bool - Bool x == y = (x y) || (not x not y) My question

[Haskell-cafe] Re: Proof question -- (==) over Bool

2010-05-22 Thread Jon Fairbairn
R J rj248...@hotmail.com writes: I'm trying to prove that (==) is reflexive, symmetric, and transitive over the Bools, given this definition: (==):: Bool - Bool - Bool x == y = (x y) || (not x not y) Since Bool is a type, and all Haskell types include ⊥, you need to add conditions in

Re: [Haskell-cafe] Re: Proof question -- (==) over Bool

2010-05-22 Thread Alexander Solla
On May 22, 2010, at 1:32 AM, Jon Fairbairn wrote: Since Bool is a type, and all Haskell types include ⊥, you need to add conditions in your proofs to exclude it. Not really. Bottom isn't a value, so much as an expression for computations that don't refer to real values. It's close enough

<    4   5   6   7   8   9   10   11   12   13   >