[Haskell-cafe] Why this cannot be compiled?

2009-07-13 Thread Magicloud Magiclouds
Hi, The following code failed to compiled, with error: Attribute.hs:46:91: Couldn't match expected type `[t]' against inferred type `(a, String)' In the expression: (color_, rest_) In a case alternative: [(color_, rest_)] - (color_, rest_) In the expression:

Re: [Haskell-cafe] Why this cannot be compiled?

2009-07-13 Thread Ketil Malde
Magicloud Magiclouds magicloud.magiclo...@gmail.com writes: 43 instance Read Attribute where 44 readsPrec _ str = [ (mkAttr attr_ color, rest) | (attr_, rest1) - lex str 45 , (color, rest) - case reads rest1 of 46

Re: [Haskell-cafe] Why this cannot be compiled?

2009-07-13 Thread Magicloud Magiclouds
Hum I must lost my mind Thank you. On Mon, Jul 13, 2009 at 3:33 PM, Ketil Maldeke...@malde.org wrote: Magicloud Magiclouds magicloud.magiclo...@gmail.com writes:  43 instance Read Attribute where  44   readsPrec _ str = [ (mkAttr attr_ color, rest) | (attr_, rest1) - lex str  45    

[Haskell-cafe] Re: Hylomorphisms (was: excercise - a completely lazy sorting algorithm)

2009-07-13 Thread Heinrich Apfelmus
Brent Yorgey wrote: Raynor Vliegendhart wrote: One of the examples I tried was: hylo (unfoldr (\a - Just (a,a))) head $ 42 This expression fails to determinate. Here are two examples copumpkin tried on IRC: copumpkin let hylo f g = g . fmap (hylo f g) . f in hylo (flip replicate

[Haskell-cafe] Are GADTs what I need?

2009-07-13 Thread Kev Mahoney
Hi there, I'm currently writing an interpreter that I would like to be able to use with other haskell programs. I would like to be able to pass along arbitrary types though the interpreter. I've seen hints that GADTs can do this, but I am having trouble understanding them. So far, I've learnt

Re: [Haskell-cafe] haskell.org: what can be improved causing what efforts?

2009-07-13 Thread Matthias Görgens
code snippet: no hello world please. That's not a way to judge a language! But: a random haskell one line snippet with explanation would be cool. Perhaps a solution to a problem like the ones you can find on Project Euler (http://projecteuler.net/index.php?section=problems). Of course you

Re: [Haskell-cafe] Type families and polymorphism

2009-07-13 Thread Jeremy Yallop
Dan Doel wrote: Hope that helps. It does, thanks! Jeremy -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] Are GADTs what I need?

2009-07-13 Thread Chris Eidhof
Hey Kev, The types are thrown away during compile time. Therefore, if you have a constructor VWrapper :: a - Value nothing is known about that a when you scrutinize it. What you could do, however, is something like this: data Value a where VInt :: Integer - Value Integer ...

Re: [Haskell-cafe] haskell.org: what can be improved causing what efforts?

2009-07-13 Thread Henk-Jan van Tuyl
On Mon, 13 Jul 2009 12:43:07 +0200, Matthias Görgens matthias.goerg...@googlemail.com wrote: code snippet: no hello world please. That's not a way to judge a language! But: a random haskell one line snippet with explanation would be cool. Perhaps a solution to a problem like the ones you

Re: [Haskell-cafe] haskell.org: what can be improved causing what efforts?

2009-07-13 Thread Matthias Görgens
I like the quicksort example at http://www.haskell.org/haskellwiki/Introduction very much; it shows how much time you can save when you use Haskell. Nice idea. Perhaps use a merge sort, because that is actually useful, because it does not degenerate for large lists. Matthias.

Re[2]: [Haskell-cafe] haskell.org: what can be improved causing what efforts?

2009-07-13 Thread Bulat Ziganshin
Hello Matthias, Monday, July 13, 2009, 6:05:06 PM, you wrote: I like the quicksort example at Nice idea. Perhaps use a merge sort, because that is actually useful, because it does not degenerate for large lists. Great idea if we want to keep Haskell community compact :))) -- Best

Re: Re[2]: [Haskell-cafe] haskell.org: what can be improved causing what efforts?

2009-07-13 Thread Matthias Görgens
Nice idea.  Perhaps use a merge sort, because that is actually useful, because it does not degenerate for large lists. Great idea if we want to keep Haskell community compact :))) Or stay with quicksort --- which is treesort. :o) ___ Haskell-Cafe

Re: [Haskell-cafe] Are GADTs what I need?

2009-07-13 Thread Chris Eidhof
Then you could add a specific constructor for String. The main point is: the case construct only works for values, not for types. There is no typecase construct. If you want to have certain restrictions on the 'a', such as the Show class, you could also do something like this: data Value

Re: [Haskell-cafe] ANN: AC-Vector, AC-Colour and AC-EasyRaster-GTK

2009-07-13 Thread Robert Greayer
It’s tempting to say, we should use the original English, which is British English. Some suggest the original English remained in Britain when the North American colonies were founded; others claim it was brought to the Americas by the British settlers, leaving a pale imitation back in Britain.

Re: [Haskell-cafe] Are GADTs what I need?

2009-07-13 Thread Kev Mahoney
Oops, wrong mail account for my last email. Apologies. What I'm trying to accomplish is being able to write haskell libraries for the interpreter that don't use the interpreter's predefined Value types, without having to edit the Value type itself and add a new constructor (i.e. it's abstracted

Re: [Haskell-cafe] Are GADTs what I need?

2009-07-13 Thread Chaddaï Fouché
On Mon, Jul 13, 2009 at 12:41 PM, Kev Mahoneymaill...@kevinmahoney.co.uk wrote: So far, I've learnt you can do this: data Value where VInt :: Integer - Value ... VWrapper :: a - Value which can let you encode arbitrary 'dynamic' types into Value. I was hoping to be able to pattern match

[Haskell-cafe] Questions about haskell CPP macros

2009-07-13 Thread Matthew Elder
Hello Cafe, I am trying to improve the error reporting in my sendfile library, and I know I can find out the current file name and line number with something like this: {-# LANGUAGE CPP #-} main = putStrLn (__FILE__ ++ : ++ show __LINE__) This outputs: test.hs:2 Unfortunately, if your file is

Re: [Haskell-cafe] Are GADTs what I need?

2009-07-13 Thread Kev Mahoney
Thanks, I hadn't noticed Data.Dynamic. It never even occurred to me that something like this would be in the standard libraries. It looks like it's precisely what I was looking for, after a brief scan of the documentation. I will report back if I bump into any problems with it 2009/7/13 Chaddaï

Re: [Haskell-cafe] Are GADTs what I need?

2009-07-13 Thread Ryan Ingram
On Mon, Jul 13, 2009 at 9:18 AM, Kev Mahoneymaill...@kevinmahoney.co.uk wrote: That said, I think I may defer this until I understand the ins and outs of Haskell's type system a little better. I think a parametrized type will be the only way to do it. The only reason I thought GADTs may be

Re: [Haskell-cafe] Questions about haskell CPP macros

2009-07-13 Thread Claus Reinke
I am trying to improve the error reporting in my sendfile library, and I know I can find out the current file name and line number with something like this: {-# LANGUAGE CPP #-} main = putStrLn (__FILE__ ++ : ++ show __LINE__) This outputs: test.hs:2 Unfortunately, if your file is in a

Re: [Haskell-cafe] Questions about haskell CPP macros

2009-07-13 Thread Stephan Friedrichs
Matthew Elder wrote: {-# LANGUAGE CPP #-} main = putStrLn (__FILE__ ++ : ++ show __LINE__) This outputs: test.hs:2 Unfortunately, if your file is in a hierarchy of folders, this flat file name doesn't give much context. Is there a macro to find out the current module? IE if I had a

Re: [Haskell-cafe] Questions about haskell CPP macros

2009-07-13 Thread Malcolm Wallace
{-# LANGUAGE CPP #-} main = putStrLn (__FILE__ ++ : ++ show __LINE__) This outputs: test.hs:2 if I had a module Foo.Bar.Car.MyModule, I would like to be able to output something like this on error: Foo.Bar.Car.MyModule:2 It works for me. If you place that text in Try/Me.hs and call

Re: [Haskell-cafe] Are GADTs what I need?

2009-07-13 Thread Luke Palmer
On Mon, Jul 13, 2009 at 6:09 AM, Chris Eidhof ch...@eidhof.nl wrote: Hey Kev, The types are thrown away during compile time. Therefore, if you have a constructor VWrapper :: a - Value nothing is known about that a when you scrutinize it. What you could do, however, is something like this:

Re: [Haskell-cafe] Removing polymorphism from type classes (viz. Functor)

2009-07-13 Thread Henning Thielemann
George Pollard schrieb: Ok, so I have a small idea I'm trying to work on; call it a Prelude-rewrite if you want. For this I want to be able to have the hierarchy Functor → Applicative → Monad. For Functor, I would like to be able to implement it for a wider variety of types, as there are

Re: [Haskell-cafe] Questions about haskell CPP macros

2009-07-13 Thread Stephan Friedrichs
Malcolm Wallace wrote: {-# LANGUAGE CPP #-} main = putStrLn (__FILE__ ++ : ++ show __LINE__) This outputs: test.hs:2 if I had a module Foo.Bar.Car.MyModule, I would like to be able to output something like this on error: Foo.Bar.Car.MyModule:2 It works for me. If you place that text

[Haskell-cafe] Example for formatted show in HStringTemplate

2009-07-13 Thread Kemps-Benedix Torsten
Hello, is there a working example of how to use the format clause with HStringTemplate, e.g. for Data.Time.Day? I think, if there is a parameter $day$, a reasonable template might contain e.g.: $day;format=%d.%b.%Y$ But I only get toModifiedJulianDay: [54960] as the result which corresponds

Re: [Haskell-cafe] Removing polymorphism from type classes (viz. Functor)

2009-07-13 Thread George Pollard
It does seem that having quantified contexts would make this *much* easier... ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

[Haskell-cafe] How to Read this?

2009-07-13 Thread Magicloud Magiclouds
Hi, I have a data structure, which shows like this: AttrBgColor {bgColor = Color 0 0 0} And the following is my Read code. But it failed parsing 31 instance Read Attribute where 32 readsPrec _ str = [ (mkAttr attr_ color, rest) | (attr_, rest1) - lex str 33

[Haskell-cafe] Re: Are GADTs what I need?

2009-07-13 Thread Ashley Yakeley
Ryan Ingram wrote: data Type a where TInt :: Type Int TBool :: Type Bool TChar :: Type Char TList :: Type a - Type [a] TFun :: Type a - Type b - Type (a - b) Type here is what I call a simple type witness. Simple type witnesses are useful because they can be compared by value,