[Haskell-cafe] Having trouble with zip12..

2008-07-06 Thread Michael Feathers



I have some code that looks like this and I'm having trouble with it:


zip12 ((tails . nub) flightPaths) wayPoints etopsPackets (hd geoCaches)
  groundSpeeds headings (map windShift headings) (regulations !! 2)
  (foldr (\|/) (tail pathDistances)) [ghy x | x - [1..], full x]
  (nub . nub) arrivalSchedule


The domain is air traffic control and I need to generate 12-tuples for 
aircraft that are within a particular radius of the tower.


When I evaluate that expression with 'take 4' it works fine.  When I 
evaluate it with 'take 6' it works as well.  But, when I evaluate it 
with 'take 5' I get the following runtime error from H# in Visual Studio 
(it runs fine on the command line).  This is particularly odd because 
I'm not using Sql.




The type initializer for 'System.Data.SqlClient.SqlConnection' threw an 
exception.
Exception (TypeInitializationException): Source=System.Data; 
Target=null; Tag=null; TypeName=System.Data.SqlClient.SqlConnection;
Message = The type initializer for 
'System.Data.SqlClient.SqlConnection' threw an exception.
InnerException (TypeInitializationException): Source=System.Data; 
Target=null; Tag=null;
Message = The type initializer for 
'System.Data.SqlClient.SqlConnectionFactory' threw an exception.

StackTrace =  at System.Data.SqlClient.SqlConnection..cctor()
InnerException (TypeInitializationException): Source=System.Data; 
Target=null; Tag=null;
Message = The type initializer for 
'System.Data.SqlClient.SqlPerformanceCounters' threw an exception.

StackTrace =
 at System.Data.SqlClient.SqlConnectionFactory..ctor()
at System.Data.SqlClient.SqlConnectionFactory..cctor()
InnerException (ConfigurationErrorsException): 
Source=System.Configuration; Target=null; Tag=null; Line=21;

Message =
The value of the property 'traceOutputOptions' cannot be parsed. The 
error is: The enumeration value must be one of the following: None, 
LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, 
Callstack. (C:\Documents and
Settings\Paey\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config 
line 21)

StackTrace =
 at System.Configuration.BaseConfigurationRecord.EvaluateOne(String[] 
keys, SectionInput input, Boolean isTrusted, FactoryRecord 
factoryRecord, SectionRecord sectionRecord, Object parentResult)
at System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord 
factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean 
getLkg, Boolean getRuntimeObject, Object result, Object 
resultRuntimeObject)
at 
System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String 
configKey, Boolean getLkg, Boolean checkPermission, Boolean 
getRuntimeObject, Boolean requestIsHere, Object result, Object 
resultRuntimeObject)
at 
System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String 
configKey, Boolean getLkg, Boolean checkPermission, Boolean 
getRuntimeObject, Boolean requestIsHere, Object result, Object 
resultRuntimeObject)
at 
System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String 
configKey, Boolean getLkg, Boolean ch... (truncated) ...olean 
checkPermission)

at System.Configuration.BaseConfigurationRecord.GetSection(String configKey)
at 
System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String 
sectionName)

at System.Configuration.ConfigurationManager.GetSection(String sectionName)
at System.Configuration.PrivilegedConfigurationManager.GetSection(String 
sectionName)

at System.Diagnostics.DiagnosticsConfiguration.GetConfigSection()
at System.Diagnostics.DiagnosticsConfiguration.Initialize()
at System.Diagnostics.Switch.InitializeConfigSettings()
at System.Diagnostics.Switch.InitializeWithStatus()
at System.Diagnostics.Switch.get_SwitchSetting()
at System.Diagnostics.TraceSwitch.get_Level()
at System.Data.ProviderBase.DbConnectionPoolCounters..ctor(String 
categoryName, String categoryHelp)

at System.Data.SqlClient.SqlPerformanceCounters..ctor()
at System.Data.SqlClient.SqlPerformanceCounters..cctor()
BareMessage = The value of the property 'traceOutputOptions' cannot be 
parsed. The error is: The enumeration value must be one of the 
following: None, LogicalOperationStack, DateTime, Timestamp, ProcessId, 
ThreadId, Callstack.
Filename = C:\Documents and 
Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config

Errors (ConfigurationException[]): Length=1; Rank=1; Count=1;
#0 (ConfigurationErrorsException): Source=null; Target=null; Tag=null; 
StackTrace=null; BareMessage=(-BareMessage); Filename=(-Filename); 
Line=21;

Message =
The value of the property 'traceOutputOptions' cannot be parsed. The 
error is: The enumeration value must be one of the following: None, 
LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, 
Callstack. (C:\Documents and
Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config 
line 21)

Errors (ConfigurationException[]): Length=1; Rank=1; Count=1;
#0 (ConfigurationErrorsException): 

Re: [Haskell-cafe] Having trouble with zip12..

2008-07-06 Thread Don Stewart
mfeathers:
 
 
 I have some code that looks like this and I'm having trouble with it:
 
 
 zip12 ((tails . nub) flightPaths) wayPoints etopsPackets (hd geoCaches)
   groundSpeeds headings (map windShift headings) (regulations !! 2)
   (foldr (\|/) (tail pathDistances)) [ghy x | x - [1..], full x]
   (nub . nub) arrivalSchedule
 
 The domain is air traffic control and I need to generate 12-tuples for 
 aircraft that are within a particular radius of the tower.

12 tuples are really really unusual. It sounds like perhaps you should
be using a custom data type here.

data Aircraft = Aircraft
{ wayPoints= currentWayPoints
, groundSpeeds = ...
, headings = ...
,  etc ...
}


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


Re: [Haskell-cafe] Having trouble with zip12..

2008-07-06 Thread Paul Visschers
You're zipping 12 lists here, so how about testing each list
individually? This will narrow down the problem considerably.

Michael Feathers wrote:
 
 
 I have some code that looks like this and I'm having trouble with it:
 
 
 zip12 ((tails . nub) flightPaths) wayPoints etopsPackets (hd geoCaches)
   groundSpeeds headings (map windShift headings) (regulations !! 2)
   (foldr (\|/) (tail pathDistances)) [ghy x | x - [1..], full x]
   (nub . nub) arrivalSchedule
 
 
 The domain is air traffic control and I need to generate 12-tuples for
 aircraft that are within a particular radius of the tower.
 
 When I evaluate that expression with 'take 4' it works fine.  When I
 evaluate it with 'take 6' it works as well.  But, when I evaluate it
 with 'take 5' I get the following runtime error from H# in Visual Studio
 (it runs fine on the command line).  This is particularly odd because
 I'm not using Sql.
 
 
 
 The type initializer for 'System.Data.SqlClient.SqlConnection' threw an
 exception.
 Exception (TypeInitializationException): Source=System.Data;
 Target=null; Tag=null; TypeName=System.Data.SqlClient.SqlConnection;
 Message = The type initializer for
 'System.Data.SqlClient.SqlConnection' threw an exception.
 InnerException (TypeInitializationException): Source=System.Data;
 Target=null; Tag=null;
 Message = The type initializer for
 'System.Data.SqlClient.SqlConnectionFactory' threw an exception.
 StackTrace =  at System.Data.SqlClient.SqlConnection..cctor()
 InnerException (TypeInitializationException): Source=System.Data;
 Target=null; Tag=null;
 Message = The type initializer for
 'System.Data.SqlClient.SqlPerformanceCounters' threw an exception.
 StackTrace =
  at System.Data.SqlClient.SqlConnectionFactory..ctor()
 at System.Data.SqlClient.SqlConnectionFactory..cctor()
 InnerException (ConfigurationErrorsException):
 Source=System.Configuration; Target=null; Tag=null; Line=21;
 Message =
 The value of the property 'traceOutputOptions' cannot be parsed. The
 error is: The enumeration value must be one of the following: None,
 LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId,
 Callstack. (C:\Documents and
 Settings\Paey\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config
 line 21)
 StackTrace =
  at System.Configuration.BaseConfigurationRecord.EvaluateOne(String[]
 keys, SectionInput input, Boolean isTrusted, FactoryRecord
 factoryRecord, SectionRecord sectionRecord, Object parentResult)
 at System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord
 factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean
 getLkg, Boolean getRuntimeObject, Object result, Object
 resultRuntimeObject)
 at
 System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String
 configKey, Boolean getLkg, Boolean checkPermission, Boolean
 getRuntimeObject, Boolean requestIsHere, Object result, Object
 resultRuntimeObject)
 at
 System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String
 configKey, Boolean getLkg, Boolean checkPermission, Boolean
 getRuntimeObject, Boolean requestIsHere, Object result, Object
 resultRuntimeObject)
 at
 System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String
 configKey, Boolean getLkg, Boolean ch... (truncated) ...olean
 checkPermission)
 at System.Configuration.BaseConfigurationRecord.GetSection(String
 configKey)
 at
 System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String
 sectionName)
 at System.Configuration.ConfigurationManager.GetSection(String sectionName)
 at System.Configuration.PrivilegedConfigurationManager.GetSection(String
 sectionName)
 at System.Diagnostics.DiagnosticsConfiguration.GetConfigSection()
 at System.Diagnostics.DiagnosticsConfiguration.Initialize()
 at System.Diagnostics.Switch.InitializeConfigSettings()
 at System.Diagnostics.Switch.InitializeWithStatus()
 at System.Diagnostics.Switch.get_SwitchSetting()
 at System.Diagnostics.TraceSwitch.get_Level()
 at System.Data.ProviderBase.DbConnectionPoolCounters..ctor(String
 categoryName, String categoryHelp)
 at System.Data.SqlClient.SqlPerformanceCounters..ctor()
 at System.Data.SqlClient.SqlPerformanceCounters..cctor()
 BareMessage = The value of the property 'traceOutputOptions' cannot be
 parsed. The error is: The enumeration value must be one of the
 following: None, LogicalOperationStack, DateTime, Timestamp, ProcessId,
 ThreadId, Callstack.
 Filename = C:\Documents and
 Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config
 Errors (ConfigurationException[]): Length=1; Rank=1; Count=1;
 #0 (ConfigurationErrorsException): Source=null; Target=null; Tag=null;
 StackTrace=null; BareMessage=(-BareMessage); Filename=(-Filename);
 Line=21;
 Message =
 The value of the property 'traceOutputOptions' cannot be parsed. The
 error is: The enumeration value must be one of the following: None,
 LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId,
 Callstack. 

Re: [Haskell-cafe] Having trouble with zip12..

2008-07-06 Thread Tony Morris
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Michael Feathers wrote:


 I have some code that looks like this and I'm having trouble with
 it:


 zip12 ((tails . nub) flightPaths) wayPoints etopsPackets (hd
 geoCaches) groundSpeeds headings (map windShift headings)
 (regulations !! 2) (foldr (\|/) (tail pathDistances)) [ghy x | x -
 [1..], full x] (nub . nub) arrivalSchedule

Hi Michael,
Sorry to distract from your issue, but I note that (nub . nub) can be
replaced with just 'nub' since the function nub is idempotent (f . f
== f).

dibblego @check \x - (nub . nub) x == nub x -- is nub idempotent?
lambdabot  OK, passed 500 tests.

- --
Tony Morris
http://tmorris.net/

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFIcS9LmnpgrYe6r60RAiDOAKCJlDaqNd5ssgxrUrrHee75WGzhbgCfftdn
70+4isXh4zaoYly0da2Gdk8=
=ryfF
-END PGP SIGNATURE-

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


Re: [Haskell-cafe] Having trouble with zip12..

2008-07-06 Thread Michael Feathers


Sorry guys.  I was just bored on a Sunday afternoon so I thought I'd 
type up a little joke.  I thought to myself Gee, how outrageous can I 
make it?


1) Using and debugging a zip12 function.
2) That fails only on 'take 5' (Brubeck fans take note)
3) Has some absurd arguments like (nub . nub)
4) Is embedded in an air traffic control system
5) Is written in a Microsoft variant of Haskell called H#
6) Silently makes SQL calls when evaluating a pure function
7) Yields an mile long stack trace

Sorry all.  Boredom made me do it,

Michael

Paul Visschers wrote:

You're zipping 12 lists here, so how about testing each list
individually? This will narrow down the problem considerably.

Michael Feathers wrote:


I have some code that looks like this and I'm having trouble with it:


zip12 ((tails . nub) flightPaths) wayPoints etopsPackets (hd geoCaches)
  groundSpeeds headings (map windShift headings) (regulations !! 2)
  (foldr (\|/) (tail pathDistances)) [ghy x | x - [1..], full x]
  (nub . nub) arrivalSchedule


The domain is air traffic control and I need to generate 12-tuples for
aircraft that are within a particular radius of the tower.

When I evaluate that expression with 'take 4' it works fine.  When I
evaluate it with 'take 6' it works as well.  But, when I evaluate it
with 'take 5' I get the following runtime error from H# in Visual Studio
(it runs fine on the command line).  This is particularly odd because
I'm not using Sql.



The type initializer for 'System.Data.SqlClient.SqlConnection' threw an
exception.
Exception (TypeInitializationException): Source=System.Data;
Target=null; Tag=null; TypeName=System.Data.SqlClient.SqlConnection;
Message = The type initializer for
'System.Data.SqlClient.SqlConnection' threw an exception.
InnerException (TypeInitializationException): Source=System.Data;
Target=null; Tag=null;
Message = The type initializer for
'System.Data.SqlClient.SqlConnectionFactory' threw an exception.
StackTrace =  at System.Data.SqlClient.SqlConnection..cctor()
InnerException (TypeInitializationException): Source=System.Data;
Target=null; Tag=null;
Message = The type initializer for
'System.Data.SqlClient.SqlPerformanceCounters' threw an exception.
StackTrace =
 at System.Data.SqlClient.SqlConnectionFactory..ctor()
at System.Data.SqlClient.SqlConnectionFactory..cctor()
InnerException (ConfigurationErrorsException):
Source=System.Configuration; Target=null; Tag=null; Line=21;
Message =
The value of the property 'traceOutputOptions' cannot be parsed. The
error is: The enumeration value must be one of the following: None,
LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId,
Callstack. (C:\Documents and
Settings\Paey\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config
line 21)
StackTrace =
 at System.Configuration.BaseConfigurationRecord.EvaluateOne(String[]
keys, SectionInput input, Boolean isTrusted, FactoryRecord
factoryRecord, SectionRecord sectionRecord, Object parentResult)
at System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord
factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean
getLkg, Boolean getRuntimeObject, Object result, Object
resultRuntimeObject)
at
System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String
configKey, Boolean getLkg, Boolean checkPermission, Boolean
getRuntimeObject, Boolean requestIsHere, Object result, Object
resultRuntimeObject)
at
System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String
configKey, Boolean getLkg, Boolean checkPermission, Boolean
getRuntimeObject, Boolean requestIsHere, Object result, Object
resultRuntimeObject)
at
System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String
configKey, Boolean getLkg, Boolean ch... (truncated) ...olean
checkPermission)
at System.Configuration.BaseConfigurationRecord.GetSection(String
configKey)
at
System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String
sectionName)
at System.Configuration.ConfigurationManager.GetSection(String sectionName)
at System.Configuration.PrivilegedConfigurationManager.GetSection(String
sectionName)
at System.Diagnostics.DiagnosticsConfiguration.GetConfigSection()
at System.Diagnostics.DiagnosticsConfiguration.Initialize()
at System.Diagnostics.Switch.InitializeConfigSettings()
at System.Diagnostics.Switch.InitializeWithStatus()
at System.Diagnostics.Switch.get_SwitchSetting()
at System.Diagnostics.TraceSwitch.get_Level()
at System.Data.ProviderBase.DbConnectionPoolCounters..ctor(String
categoryName, String categoryHelp)
at System.Data.SqlClient.SqlPerformanceCounters..ctor()
at System.Data.SqlClient.SqlPerformanceCounters..cctor()
BareMessage = The value of the property 'traceOutputOptions' cannot be
parsed. The error is: The enumeration value must be one of the
following: None, LogicalOperationStack, DateTime, Timestamp, ProcessId,
ThreadId, Callstack.
Filename = C:\Documents and

Re: [Haskell-cafe] Having trouble with zip12..

2008-07-06 Thread Don Stewart
I win, almost ...

13:13:18 dons dolio: yeah, it was ... almost ... an April 1 style post 

:)

And yes, this was truly shocking on a number of levels. However, we have
people doing a lot of weird things with Haskell these days, so its not
as absurd that someone would be hacking up a zip12 for an air traffic
control system on some MS platform, with SQL in the backend, as it might
have been a few years ago :)

mfeathers:
 
 Sorry guys.  I was just bored on a Sunday afternoon so I thought I'd 
 type up a little joke.  I thought to myself Gee, how outrageous can I 
 make it?
 
 1) Using and debugging a zip12 function.
 2) That fails only on 'take 5' (Brubeck fans take note)
 3) Has some absurd arguments like (nub . nub)
 4) Is embedded in an air traffic control system
 5) Is written in a Microsoft variant of Haskell called H#
 6) Silently makes SQL calls when evaluating a pure function
 7) Yields an mile long stack trace
 
 Sorry all.  Boredom made me do it,
 
 Michael
 
 Paul Visschers wrote:
 You're zipping 12 lists here, so how about testing each list
 individually? This will narrow down the problem considerably.
 
 Michael Feathers wrote:
 
 I have some code that looks like this and I'm having trouble with it:
 
 
 zip12 ((tails . nub) flightPaths) wayPoints etopsPackets (hd geoCaches)
   groundSpeeds headings (map windShift headings) (regulations !! 2)
   (foldr (\|/) (tail pathDistances)) [ghy x | x - [1..], full x]
   (nub . nub) arrivalSchedule
 
 
 The domain is air traffic control and I need to generate 12-tuples for
 aircraft that are within a particular radius of the tower.
 
 When I evaluate that expression with 'take 4' it works fine.  When I
 evaluate it with 'take 6' it works as well.  But, when I evaluate it
 with 'take 5' I get the following runtime error from H# in Visual Studio
 (it runs fine on the command line).  This is particularly odd because
 I'm not using Sql.
 
 
 
 The type initializer for 'System.Data.SqlClient.SqlConnection' threw an
 exception.
 Exception (TypeInitializationException): Source=System.Data;
 Target=null; Tag=null; TypeName=System.Data.SqlClient.SqlConnection;
 Message = The type initializer for
 'System.Data.SqlClient.SqlConnection' threw an exception.
 InnerException (TypeInitializationException): Source=System.Data;
 Target=null; Tag=null;
 Message = The type initializer for
 'System.Data.SqlClient.SqlConnectionFactory' threw an exception.
 StackTrace =  at System.Data.SqlClient.SqlConnection..cctor()
 InnerException (TypeInitializationException): Source=System.Data;
 Target=null; Tag=null;
 Message = The type initializer for
 'System.Data.SqlClient.SqlPerformanceCounters' threw an exception.
 StackTrace =
  at System.Data.SqlClient.SqlConnectionFactory..ctor()
 at System.Data.SqlClient.SqlConnectionFactory..cctor()
 InnerException (ConfigurationErrorsException):
 Source=System.Configuration; Target=null; Tag=null; Line=21;
 Message =
 The value of the property 'traceOutputOptions' cannot be parsed. The
 error is: The enumeration value must be one of the following: None,
 LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId,
 Callstack. (C:\Documents and
 Settings\Paey\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config
 line 21)
 StackTrace =
  at System.Configuration.BaseConfigurationRecord.EvaluateOne(String[]
 keys, SectionInput input, Boolean isTrusted, FactoryRecord
 factoryRecord, SectionRecord sectionRecord, Object parentResult)
 at System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord
 factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean
 getLkg, Boolean getRuntimeObject, Object result, Object
 resultRuntimeObject)
 at
 System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String
 configKey, Boolean getLkg, Boolean checkPermission, Boolean
 getRuntimeObject, Boolean requestIsHere, Object result, Object
 resultRuntimeObject)
 at
 System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String
 configKey, Boolean getLkg, Boolean checkPermission, Boolean
 getRuntimeObject, Boolean requestIsHere, Object result, Object
 resultRuntimeObject)
 at
 System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String
 configKey, Boolean getLkg, Boolean ch... (truncated) ...olean
 checkPermission)
 at System.Configuration.BaseConfigurationRecord.GetSection(String
 configKey)
 at
 System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String
 sectionName)
 at System.Configuration.ConfigurationManager.GetSection(String 
 sectionName)
 at System.Configuration.PrivilegedConfigurationManager.GetSection(String
 sectionName)
 at System.Diagnostics.DiagnosticsConfiguration.GetConfigSection()
 at System.Diagnostics.DiagnosticsConfiguration.Initialize()
 at System.Diagnostics.Switch.InitializeConfigSettings()
 at System.Diagnostics.Switch.InitializeWithStatus()
 at System.Diagnostics.Switch.get_SwitchSetting()
 at 

Re: [Haskell-cafe] Having trouble with zip12..

2008-07-06 Thread Andrew Wagner
Wow. Where did you come up with the stack trace? That's...impressive.

On Sun, Jul 6, 2008 at 5:07 PM, Don Stewart [EMAIL PROTECTED] wrote:
 I win, almost ...

13:13:18 dons dolio: yeah, it was ... almost ... an April 1 style post

 :)

 And yes, this was truly shocking on a number of levels. However, we have
 people doing a lot of weird things with Haskell these days, so its not
 as absurd that someone would be hacking up a zip12 for an air traffic
 control system on some MS platform, with SQL in the backend, as it might
 have been a few years ago :)

 mfeathers:

 Sorry guys.  I was just bored on a Sunday afternoon so I thought I'd
 type up a little joke.  I thought to myself Gee, how outrageous can I
 make it?

 1) Using and debugging a zip12 function.
 2) That fails only on 'take 5' (Brubeck fans take note)
 3) Has some absurd arguments like (nub . nub)
 4) Is embedded in an air traffic control system
 5) Is written in a Microsoft variant of Haskell called H#
 6) Silently makes SQL calls when evaluating a pure function
 7) Yields an mile long stack trace

 Sorry all.  Boredom made me do it,

 Michael

 Paul Visschers wrote:
 You're zipping 12 lists here, so how about testing each list
 individually? This will narrow down the problem considerably.
 
 Michael Feathers wrote:
 
 I have some code that looks like this and I'm having trouble with it:
 
 
 zip12 ((tails . nub) flightPaths) wayPoints etopsPackets (hd geoCaches)
   groundSpeeds headings (map windShift headings) (regulations !! 2)
   (foldr (\|/) (tail pathDistances)) [ghy x | x - [1..], full x]
   (nub . nub) arrivalSchedule
 
 
 The domain is air traffic control and I need to generate 12-tuples for
 aircraft that are within a particular radius of the tower.
 
 When I evaluate that expression with 'take 4' it works fine.  When I
 evaluate it with 'take 6' it works as well.  But, when I evaluate it
 with 'take 5' I get the following runtime error from H# in Visual Studio
 (it runs fine on the command line).  This is particularly odd because
 I'm not using Sql.
 
 
 
 The type initializer for 'System.Data.SqlClient.SqlConnection' threw an
 exception.
 Exception (TypeInitializationException): Source=System.Data;
 Target=null; Tag=null; TypeName=System.Data.SqlClient.SqlConnection;
 Message = The type initializer for
 'System.Data.SqlClient.SqlConnection' threw an exception.
 InnerException (TypeInitializationException): Source=System.Data;
 Target=null; Tag=null;
 Message = The type initializer for
 'System.Data.SqlClient.SqlConnectionFactory' threw an exception.
 StackTrace =  at System.Data.SqlClient.SqlConnection..cctor()
 InnerException (TypeInitializationException): Source=System.Data;
 Target=null; Tag=null;
 Message = The type initializer for
 'System.Data.SqlClient.SqlPerformanceCounters' threw an exception.
 StackTrace =
  at System.Data.SqlClient.SqlConnectionFactory..ctor()
 at System.Data.SqlClient.SqlConnectionFactory..cctor()
 InnerException (ConfigurationErrorsException):
 Source=System.Configuration; Target=null; Tag=null; Line=21;
 Message =
 The value of the property 'traceOutputOptions' cannot be parsed. The
 error is: The enumeration value must be one of the following: None,
 LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId,
 Callstack. (C:\Documents and
 Settings\Paey\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config
 line 21)
 StackTrace =
  at System.Configuration.BaseConfigurationRecord.EvaluateOne(String[]
 keys, SectionInput input, Boolean isTrusted, FactoryRecord
 factoryRecord, SectionRecord sectionRecord, Object parentResult)
 at System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord
 factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean
 getLkg, Boolean getRuntimeObject, Object result, Object
 resultRuntimeObject)
 at
 System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String
 configKey, Boolean getLkg, Boolean checkPermission, Boolean
 getRuntimeObject, Boolean requestIsHere, Object result, Object
 resultRuntimeObject)
 at
 System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String
 configKey, Boolean getLkg, Boolean checkPermission, Boolean
 getRuntimeObject, Boolean requestIsHere, Object result, Object
 resultRuntimeObject)
 at
 System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String
 configKey, Boolean getLkg, Boolean ch... (truncated) ...olean
 checkPermission)
 at System.Configuration.BaseConfigurationRecord.GetSection(String
 configKey)
 at
 System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String
 sectionName)
 at System.Configuration.ConfigurationManager.GetSection(String
 sectionName)
 at System.Configuration.PrivilegedConfigurationManager.GetSection(String
 sectionName)
 at System.Diagnostics.DiagnosticsConfiguration.GetConfigSection()
 at System.Diagnostics.DiagnosticsConfiguration.Initialize()
 at 

Re: [Haskell-cafe] Having trouble with zip12..

2008-07-06 Thread Michael Feathers

Don Stewart wrote:

I win, almost ...

13:13:18 dons dolio: yeah, it was ... almost ... an April 1 style post 


:)

And yes, this was truly shocking on a number of levels. However, we have
people doing a lot of weird things with Haskell these days, so its not
as absurd that someone would be hacking up a zip12 for an air traffic
control system on some MS platform, with SQL in the backend, as it might
have been a few years ago :)


:-)

Was that IRC?  Oh boy, now I have a reputation.

Michael



mfeathers:
Sorry guys.  I was just bored on a Sunday afternoon so I thought I'd 
type up a little joke.  I thought to myself Gee, how outrageous can I 
make it?


1) Using and debugging a zip12 function.
2) That fails only on 'take 5' (Brubeck fans take note)
3) Has some absurd arguments like (nub . nub)
4) Is embedded in an air traffic control system
5) Is written in a Microsoft variant of Haskell called H#
6) Silently makes SQL calls when evaluating a pure function
7) Yields an mile long stack trace

Sorry all.  Boredom made me do it,

Michael

Paul Visschers wrote:

You're zipping 12 lists here, so how about testing each list
individually? This will narrow down the problem considerably.

Michael Feathers wrote:

I have some code that looks like this and I'm having trouble with it:


zip12 ((tails . nub) flightPaths) wayPoints etopsPackets (hd geoCaches)
 groundSpeeds headings (map windShift headings) (regulations !! 2)
 (foldr (\|/) (tail pathDistances)) [ghy x | x - [1..], full x]
 (nub . nub) arrivalSchedule


The domain is air traffic control and I need to generate 12-tuples for
aircraft that are within a particular radius of the tower.

When I evaluate that expression with 'take 4' it works fine.  When I
evaluate it with 'take 6' it works as well.  But, when I evaluate it
with 'take 5' I get the following runtime error from H# in Visual Studio
(it runs fine on the command line).  This is particularly odd because
I'm not using Sql.



The type initializer for 'System.Data.SqlClient.SqlConnection' threw an
exception.
Exception (TypeInitializationException): Source=System.Data;
Target=null; Tag=null; TypeName=System.Data.SqlClient.SqlConnection;
Message = The type initializer for
'System.Data.SqlClient.SqlConnection' threw an exception.
InnerException (TypeInitializationException): Source=System.Data;
Target=null; Tag=null;
Message = The type initializer for
'System.Data.SqlClient.SqlConnectionFactory' threw an exception.
StackTrace =  at System.Data.SqlClient.SqlConnection..cctor()
InnerException (TypeInitializationException): Source=System.Data;
Target=null; Tag=null;
Message = The type initializer for
'System.Data.SqlClient.SqlPerformanceCounters' threw an exception.
StackTrace =
 at System.Data.SqlClient.SqlConnectionFactory..ctor()
at System.Data.SqlClient.SqlConnectionFactory..cctor()
InnerException (ConfigurationErrorsException):
Source=System.Configuration; Target=null; Tag=null; Line=21;
Message =
The value of the property 'traceOutputOptions' cannot be parsed. The
error is: The enumeration value must be one of the following: None,
LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId,
Callstack. (C:\Documents and
Settings\Paey\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config
line 21)
StackTrace =
 at System.Configuration.BaseConfigurationRecord.EvaluateOne(String[]
keys, SectionInput input, Boolean isTrusted, FactoryRecord
factoryRecord, SectionRecord sectionRecord, Object parentResult)
at System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord
factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean
getLkg, Boolean getRuntimeObject, Object result, Object
resultRuntimeObject)
at
System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String
configKey, Boolean getLkg, Boolean checkPermission, Boolean
getRuntimeObject, Boolean requestIsHere, Object result, Object
resultRuntimeObject)
at
System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String
configKey, Boolean getLkg, Boolean checkPermission, Boolean
getRuntimeObject, Boolean requestIsHere, Object result, Object
resultRuntimeObject)
at
System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String
configKey, Boolean getLkg, Boolean ch... (truncated) ...olean
checkPermission)
at System.Configuration.BaseConfigurationRecord.GetSection(String
configKey)
at
System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String
sectionName)
at System.Configuration.ConfigurationManager.GetSection(String 
sectionName)

at System.Configuration.PrivilegedConfigurationManager.GetSection(String
sectionName)
at System.Diagnostics.DiagnosticsConfiguration.GetConfigSection()
at System.Diagnostics.DiagnosticsConfiguration.Initialize()
at System.Diagnostics.Switch.InitializeConfigSettings()
at System.Diagnostics.Switch.InitializeWithStatus()
at System.Diagnostics.Switch.get_SwitchSetting()
at System.Diagnostics.TraceSwitch.get_Level()
at 

Re: [Haskell-cafe] Having trouble with zip12..

2008-07-06 Thread Michael Feathers

Andrew Wagner wrote:

Wow. Where did you come up with the stack trace? That's...impressive.


Pulled it from a blog.  I was actually looking for a creepy VB4 or VB5 
stack trace I saw years ago that ripped through their dynamic type 
resolution layer. Now that would've been funny. :-)


Michael



On Sun, Jul 6, 2008 at 5:07 PM, Don Stewart [EMAIL PROTECTED] wrote:

I win, almost ...

   13:13:18 dons dolio: yeah, it was ... almost ... an April 1 style post

:)

And yes, this was truly shocking on a number of levels. However, we have
people doing a lot of weird things with Haskell these days, so its not
as absurd that someone would be hacking up a zip12 for an air traffic
control system on some MS platform, with SQL in the backend, as it might
have been a few years ago :)

mfeathers:

Sorry guys.  I was just bored on a Sunday afternoon so I thought I'd
type up a little joke.  I thought to myself Gee, how outrageous can I
make it?

1) Using and debugging a zip12 function.
2) That fails only on 'take 5' (Brubeck fans take note)
3) Has some absurd arguments like (nub . nub)
4) Is embedded in an air traffic control system
5) Is written in a Microsoft variant of Haskell called H#
6) Silently makes SQL calls when evaluating a pure function
7) Yields an mile long stack trace

Sorry all.  Boredom made me do it,

Michael

Paul Visschers wrote:

You're zipping 12 lists here, so how about testing each list
individually? This will narrow down the problem considerably.

Michael Feathers wrote:

I have some code that looks like this and I'm having trouble with it:


zip12 ((tails . nub) flightPaths) wayPoints etopsPackets (hd geoCaches)
 groundSpeeds headings (map windShift headings) (regulations !! 2)
 (foldr (\|/) (tail pathDistances)) [ghy x | x - [1..], full x]
 (nub . nub) arrivalSchedule


The domain is air traffic control and I need to generate 12-tuples for
aircraft that are within a particular radius of the tower.

When I evaluate that expression with 'take 4' it works fine.  When I
evaluate it with 'take 6' it works as well.  But, when I evaluate it
with 'take 5' I get the following runtime error from H# in Visual Studio
(it runs fine on the command line).  This is particularly odd because
I'm not using Sql.



The type initializer for 'System.Data.SqlClient.SqlConnection' threw an
exception.
Exception (TypeInitializationException): Source=System.Data;
Target=null; Tag=null; TypeName=System.Data.SqlClient.SqlConnection;
Message = The type initializer for
'System.Data.SqlClient.SqlConnection' threw an exception.
InnerException (TypeInitializationException): Source=System.Data;
Target=null; Tag=null;
Message = The type initializer for
'System.Data.SqlClient.SqlConnectionFactory' threw an exception.
StackTrace =  at System.Data.SqlClient.SqlConnection..cctor()
InnerException (TypeInitializationException): Source=System.Data;
Target=null; Tag=null;
Message = The type initializer for
'System.Data.SqlClient.SqlPerformanceCounters' threw an exception.
StackTrace =
 at System.Data.SqlClient.SqlConnectionFactory..ctor()
at System.Data.SqlClient.SqlConnectionFactory..cctor()
InnerException (ConfigurationErrorsException):
Source=System.Configuration; Target=null; Tag=null; Line=21;
Message =
The value of the property 'traceOutputOptions' cannot be parsed. The
error is: The enumeration value must be one of the following: None,
LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId,
Callstack. (C:\Documents and
Settings\Paey\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config
line 21)
StackTrace =
 at System.Configuration.BaseConfigurationRecord.EvaluateOne(String[]
keys, SectionInput input, Boolean isTrusted, FactoryRecord
factoryRecord, SectionRecord sectionRecord, Object parentResult)
at System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord
factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean
getLkg, Boolean getRuntimeObject, Object result, Object
resultRuntimeObject)
at
System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String
configKey, Boolean getLkg, Boolean checkPermission, Boolean
getRuntimeObject, Boolean requestIsHere, Object result, Object
resultRuntimeObject)
at
System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String
configKey, Boolean getLkg, Boolean checkPermission, Boolean
getRuntimeObject, Boolean requestIsHere, Object result, Object
resultRuntimeObject)
at
System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String
configKey, Boolean getLkg, Boolean ch... (truncated) ...olean
checkPermission)
at System.Configuration.BaseConfigurationRecord.GetSection(String
configKey)
at
System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String
sectionName)
at System.Configuration.ConfigurationManager.GetSection(String
sectionName)
at System.Configuration.PrivilegedConfigurationManager.GetSection(String
sectionName)
at 

Re: [Haskell-cafe] Having trouble with zip12..

2008-07-06 Thread Brandon S. Allbery KF8NH


On 2008 Jul 6, at 16:47, Tony Morris wrote:


-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Michael Feathers wrote:

zip12 ((tails . nub) flightPaths) wayPoints etopsPackets (hd
geoCaches) groundSpeeds headings (map windShift headings)
(regulations !! 2) (foldr (\|/) (tail pathDistances)) [ghy x | x -
[1..], full x] (nub . nub) arrivalSchedule


Hi Michael,
Sorry to distract from your issue, but I note that (nub . nub) can be
replaced with just 'nub' since the function nub is idempotent (f . f
== f).



Or even better, with a custom nub:  in order to handle some special  
cases the Prelude nub is rather inefficient.


--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [EMAIL PROTECTED]
system administrator [openafs,heimdal,too many hats] [EMAIL PROTECTED]
electrical and computer engineering, carnegie mellon universityKF8NH


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


[Haskell-cafe] Is there a nicer way to do this?

2008-07-06 Thread Michael Feathers



segment :: Int - [a] - [[a]]
segment 0 _ = []
segment _ [] = []
segment n x = (take n x) : segment n (drop n x)


I did a version of this which used splitAt but I wasn't sure whether it 
was going to buy me anything re performance that would justify its ugliness.



Michael






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


Re: [Haskell-cafe] Is there a nicer way to do this?

2008-07-06 Thread Don Stewart
mfeathers:
 
 
 segment :: Int - [a] - [[a]]
 segment 0 _ = []
 segment _ [] = []
 segment n x = (take n x) : segment n (drop n x)

The first set of parens can go,

  segment n x = take n x : segment n (drop n x)

 
 I did a version of this which used splitAt but I wasn't sure whether it 
 was going to buy me anything re performance that would justify its ugliness.

Besides,

  splitAt n xs =  (take n xs, drop n xs)

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


Re: [Haskell-cafe] Is there a nicer way to do this?

2008-07-06 Thread John Hamilton
On Sun, Jul 6, 2008 at 16:45, Michael Feathers [EMAIL PROTECTED] wrote:


 segment :: Int - [a] - [[a]]
 segment 0 _ = []
 segment _ [] = []
 segment n x = (take n x) : segment n (drop n x)


 I did a version of this which used splitAt but I wasn't sure whether it was
 going to buy me anything re performance that would justify its ugliness.

You can use

 segment n = takeWhile (not . null) . unfoldr (Just . splitAt n)

I don't know how it compares in performance.  It's from
http://www.haskell.org/haskellwiki/Blow_your_mind

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


[Haskell-cafe] extensible data types in Haskell?

2008-07-06 Thread David Walker
Hi all,

SML conveniently contains the type exn which is an instance of an
extensible data type.  In other words, unlike normal data types that
are closed (can't admit new constructors once defined), SML's exn
type is open, allowing programmers to keep adding new alternatives
as often as they choose.  Like normal datatypes, the elimination form
for an extensible data type is a case statement (or match function).

Friends have told me that Haskell doesn't have extensible data types.
However, it seems fairly straightforward to code them up using type
classesthough the solution I'm thinking of has a little bit of
boilerplate I'd like to scrap (you have to define a new type
declaration *and* an instance of a type class with a match method)
and matching occurs through a string comparison (which can lead to
silly programmer errors if there is accidentally a typo in the
string).

Anyway, it's possible with some thought I could come up with a better
solution, but before worrying about it, I figured I'd ask if anybody
else already has a package that does this.  It seems like a pretty
natural feature to want to have.

Thanks in advance,
Dave
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Is there a nicer way to do this?

2008-07-06 Thread Evan Laforge
On Sun, Jul 6, 2008 at 5:25 PM, John Hamilton [EMAIL PROTECTED] wrote:
 On Sun, Jul 6, 2008 at 16:45, Michael Feathers [EMAIL PROTECTED] wrote:


 segment :: Int - [a] - [[a]]
 segment 0 _ = []
 segment _ [] = []
 segment n x = (take n x) : segment n (drop n x)


 I did a version of this which used splitAt but I wasn't sure whether it was
 going to buy me anything re performance that would justify its ugliness.

 You can use

  segment n = takeWhile (not . null) . unfoldr (Just . splitAt n)

 I don't know how it compares in performance.  It's from
 http://www.haskell.org/haskellwiki/Blow_your_mind

Watch out for negative numbers, though.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Is there a nicer way to do this?

2008-07-06 Thread Don Stewart
mfeathers:
 Don Stewart wrote:
 mfeathers:
 
 segment :: Int - [a] - [[a]]
 segment 0 _ = []
 segment _ [] = []
 segment n x = (take n x) : segment n (drop n x)
 
 The first set of parens can go,
 
   segment n x = take n x : segment n (drop n x)
 
 I did a version of this which used splitAt but I wasn't sure whether it 
 was going to buy me anything re performance that would justify its 
 ugliness.
 
 Besides,
 
   splitAt n xs =  (take n xs, drop n xs)
 
 Thanks.  That is odd, though.  It makes me wonder what to expect re 
 optimization.  Would the compiler/runtime know that splitAt could be 
 done in a single pass?

Not with that definition. It would require some moderately unusual fusion
combining the take and drop into a single fold with the (,) on the inside,
rather than on the outside.

However, GHC actually implements splitAt as:

splitAt (I n) ls
  | n  0   = ([], ls)
  | otherwise   = splitAt' n ls
where
splitAt' :: Int - [a] - ([a], [a])
splitAt' 0 xs = ([], xs)
splitAt' _  [EMAIL PROTECTED] = (xs, xs)
splitAt' m (x:xs) = (x:xs', xs'')
  where
(xs', xs'') = splitAt' (m - 1) xs

So there may be some benefit.

-- Don

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


[Haskell-cafe] Is there anything manifestly stupid about this code?

2008-07-06 Thread Michael Feathers


Decided a while ago to write some code to calculate the Mandelbrot set 
using the escape iterations algorithm.  Discovered after mulling it 
about that I could just built it as an infinite list of infinite lists 
and then extract any rectangle of values that I wanted:


type Point = (Double, Double)

sq :: Double - Double
sq x = x ^ 2

translate :: Point - Point - Point
translate (r0, i0) (r1, i1) =
  (r0 + r1, i0 + i1)

mandel :: Point - Point
mandel (r, i) =
  (sq r + sq i, 2 * r * i)

notEscaped :: Point - Bool
notEscaped (r, i) =
  (sq r + sq i) = 4.0

trajectory :: (Point - Point) - [Point]
trajectory pointFunction =
  takeWhile notEscaped $ iterate pointFunction seed
where seed = (0.0, 0.0)

escapeIterations :: (Point - Point) - Int
escapeIterations =
  length . tail . take 1024 . trajectory

mandelbrot :: Double - [[Int]]
mandelbrot incrementSize =
  [[ escapeIterations $ translate (x, y) . mandel
| x - increments]
| y - increments] where
increments = [0.0, incrementSize .. ]

window :: (Int, Int) - (Int, Int) - [[a]] - [[a]]
window (x0, y0) (x1, y1) = range x0 x1 . map (range y0 y1) where
  range m n = take (n - m) . drop m


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


Re: [Haskell-cafe] Is there anything manifestly stupid about this code?

2008-07-06 Thread Derek Elkins
To answer the question in your subject, yes!  We have a complex type.
Not only does that make the code simpler and more obvious and idiomatic,
but it's also more efficient because for this use you'd really prefer a
strict pair type for Point, and complex is strict in it's components.

On Sun, 2008-07-06 at 21:02 -0400, Michael Feathers wrote:
 Decided a while ago to write some code to calculate the Mandelbrot set 
 using the escape iterations algorithm.  Discovered after mulling it 
 about that I could just built it as an infinite list of infinite lists 
 and then extract any rectangle of values that I wanted:
 
 type Point = (Double, Double)

 sq :: Double - Double
 sq x = x ^ 2
 
 translate :: Point - Point - Point
 translate (r0, i0) (r1, i1) =
(r0 + r1, i0 + i1)
 
 mandel :: Point - Point
 mandel (r, i) =
(sq r + sq i, 2 * r * i)
 
 notEscaped :: Point - Bool
 notEscaped (r, i) =
(sq r + sq i) = 4.0
 
 trajectory :: (Point - Point) - [Point]
 trajectory pointFunction =
takeWhile notEscaped $ iterate pointFunction seed
  where seed = (0.0, 0.0)
 
 escapeIterations :: (Point - Point) - Int
 escapeIterations =
length . tail . take 1024 . trajectory
 
 mandelbrot :: Double - [[Int]]
 mandelbrot incrementSize =
[[ escapeIterations $ translate (x, y) . mandel
  | x - increments]
  | y - increments] where
  increments = [0.0, incrementSize .. ]
 
 window :: (Int, Int) - (Int, Int) - [[a]] - [[a]]
 window (x0, y0) (x1, y1) = range x0 x1 . map (range y0 y1) where
range m n = take (n - m) . drop m
 
 
 ___
 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] extensible data types in Haskell?

2008-07-06 Thread Don Stewart
princedpw:
 Hi all,
 
 SML conveniently contains the type exn which is an instance of an
 extensible data type.  In other words, unlike normal data types that
 are closed (can't admit new constructors once defined), SML's exn
 type is open, allowing programmers to keep adding new alternatives
 as often as they choose.  Like normal datatypes, the elimination form
 for an extensible data type is a case statement (or match function).
 
 Friends have told me that Haskell doesn't have extensible data types.
 However, it seems fairly straightforward to code them up using type
 classesthough the solution I'm thinking of has a little bit of
 boilerplate I'd like to scrap (you have to define a new type
 declaration *and* an instance of a type class with a match method)
 and matching occurs through a string comparison (which can lead to
 silly programmer errors if there is accidentally a typo in the
 string).

You should probably use Typeable here, for the type matching, rather
than a custom matcher. class Typeable a = Extensible a, this leads to a
fairly straighforward extensible data type, where the open instance
definition lets you add variants on the fly.

 Anyway, it's possible with some thought I could come up with a better
 solution, but before worrying about it, I figured I'd ask if anybody
 else already has a package that does this.  It seems like a pretty
 natural feature to want to have.

There's a number of ways to do this, including fully statically via type
classes and existential types, or via the Dynamic type.

Googling for expression problem Haskell will turn up some things. Some
implementions of open data types in use can be found in xmonad, and the
extensible exceptions proposal here,


http://209.85.173.104/search?q=cache:xeXhle5KAqkJ:www.haskell.org/~simonmar/papers/ext-exceptions.pdf

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


[Haskell-cafe] Associative Commutative Unification

2008-07-06 Thread John D. Ramsdell
I'd like to write an obviously correct implementation of a unifier, a
program that when given two terms, finds a substitution that makes the
two terms equal.  The phrase obviously correct is meant to imply
that the clarity of the code trumps efficiency.  As near as I can
tell, high performance unifiers are full of side-effects, and
achieving the same performance without side-effects in Haskell is
difficult or impossible.

In contrast, it is easy to write obviously correct Hasklell
implementations of unifiers for freely generated term algebras.  One
can use Lawrence Paulson's code in ML for the Working Programmer as a
template or follow Martelli and Montanari's simple set of rules.

My problem is one of my operators is multiplication, which is
associative and commutative.  These two properties make unification
much more difficult.  Mark Stickel described a complete unification
algorithm for this problem, but the task of translating his
description into an obviously correct Haskell program appears to be
difficult.  For example, the algorithm requires the generation of the
basis of solutions to linear homogeneous diophantine equations.  I
haven't located an algorithm for this part yet.

If you have experience implemented equational unification in Haskell,
please share it.

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


Re: [Haskell-cafe] Associative Commutative Unification

2008-07-06 Thread Don Stewart
ramsdell0:
 I'd like to write an obviously correct implementation of a unifier, a
 program that when given two terms, finds a substitution that makes the
 two terms equal.  The phrase obviously correct is meant to imply
 that the clarity of the code trumps efficiency.  As near as I can
 tell, high performance unifiers are full of side-effects, and
 achieving the same performance without side-effects in Haskell is
 difficult or impossible.
 
 In contrast, it is easy to write obviously correct Hasklell
 implementations of unifiers for freely generated term algebras.  One
 can use Lawrence Paulson's code in ML for the Working Programmer as a
 template or follow Martelli and Montanari's simple set of rules.
 
 My problem is one of my operators is multiplication, which is
 associative and commutative.  These two properties make unification
 much more difficult.  Mark Stickel described a complete unification
 algorithm for this problem, but the task of translating his
 description into an obviously correct Haskell program appears to be
 difficult.  For example, the algorithm requires the generation of the
 basis of solutions to linear homogeneous diophantine equations.  I
 haven't located an algorithm for this part yet.
 
 If you have experience implemented equational unification in Haskell,
 please share it.

Typing Haskell in Haskell lives here,

http://hackage.haskell.org/cgi-bin/hackage-scripts/package/thih

a Haskell program that implements a Haskell typechecker, thus providing
a mathematically rigorous specification in a notation that is familiar
to Haskell users. We expect this program to fill a serious gap in
current descriptions of Haskell, both as a starting point for
discussions about existing features of the type system, and as a
platform from which to explore new proposals

Might be useful as a starting point.

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


Re: [Haskell-cafe] The state of database libraries

2008-07-06 Thread Paul Brown


On Jul 4, 2008, at 7:54 AM, Chris Eidhof wrote:

1. hdbc. I'd like to connect to MySQL, so I need the ODBC backend. I  
couldn't get this to work under OS X, while I installed myodbc,  
which seems to be broken.


FWIW, I've had good luck with the SQLite3 bindings for HDBC on MacOS  
X.  I had a bit of a hiccup with Linux, but that was only because the  
version of SQLite on the Linux box was a bit too old.  (3.2.x versus  
3.4.x on the MacOS box.)  With 3.5.9 on the Linux box, everything  
worked swimmingly.


I haven't tried the MySQL support, but I don't need it.

The timestamps on the other packages were old enough (~2007 IIRC) that  
I didn't even try 'em.


Depending on what your application is, you might get more mileage out  
of a binding to CouchDB or some other post-relational storage system.


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


[Haskell-cafe] OpenSSL.Digest linking error: EVP_mdc2

2008-07-06 Thread Ken Takusagawa
I'm using hopenssl 1.0 from hackage.  What am I doing wrong here?

$  cat test-hopenssl.hs
import OpenSSL.Digest
main=undefined

$ ghc --make test-hopenssl.hs  -lcrypto
[1 of 1] Compiling Main ( test-hopenssl.hs, test-hopenssl.o )
Linking test-hopenssl ...
/tmp/ken/lib/hopenssl-1.0/ghc-6.8.2/libHShopenssl-1.0.a(Digest.o): In
function `s2O8_info':
(.text+0xf3a): undefined reference to `EVP_mdc2'
/tmp/ken/lib/hopenssl-1.0/ghc-6.8.2/libHShopenssl-1.0.a(Digest.o): In
function `s2TQ_info':
(.text+0x1435): undefined reference to `EVP_mdc2'
collect2: ld returned 1 exit status

$ dpkg-query -S /usr/lib/libcrypto.a
libssl-dev: /usr/lib/libcrypto.a

$  dpkg-query -l libssl-dev
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Cfg-files/Unpacked/Failed-cfg/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad)
||/ Name   VersionDescription
+++-==-==-
ii  libssl-dev 0.9.8g-10.1SSL development
libraries, header files and documentation


$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 6.8.2

$ uname -a
Linux localhost 2.6.24-1-686 #1 SMP Thu May 8 02:16:39 UTC 2008 i686 GNU/Linux
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] The state of database libraries

2008-07-06 Thread Don Stewart
prb:
 
 On Jul 4, 2008, at 7:54 AM, Chris Eidhof wrote:
 
 1. hdbc. I'd like to connect to MySQL, so I need the ODBC backend. I  
 couldn't get this to work under OS X, while I installed myodbc,  
 which seems to be broken.
 
 FWIW, I've had good luck with the SQLite3 bindings for HDBC on MacOS  
 X.  I had a bit of a hiccup with Linux, but that was only because the  
 version of SQLite on the Linux box was a bit too old.  (3.2.x versus  
 3.4.x on the MacOS box.)  With 3.5.9 on the Linux box, everything  
 worked swimmingly.
 
 I haven't tried the MySQL support, but I don't need it.
 
 The timestamps on the other packages were old enough (~2007 IIRC) that  
 I didn't even try 'em.
 
 Depending on what your application is, you might get more mileage out  
 of a binding to CouchDB or some other post-relational storage system.

The YHC guys have a simple CouchDB binding too. I was thinking this
might be a nice project to actually polish up into a comprehensive
system.

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


[Haskell-cafe] not for me, guv!

2008-07-06 Thread Evan Laforge
So I wrote a big email about this mysterious message I was getting,
but then after some research and poking and debugging tracked it down
to a dangling pointer in C that was causing a callback to point to an
invalid address, which somehow worked anyway 99% of the time.

That all said, I'm not totally convinced that freeHaskellFunctionPtr:
not for me, guv! 0x23143f0 is the clearest error message ever.  Now,
if it were in a more contemporary American idiom such as wtf this ptr
ain't from MY house lol!!! I probably would have found the bug in
half the time.

Anyway, I fixed my bug and I'm happy about that, but I didn't want to
waste a chance to send an email with this title...
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] OpenSSL.Digest linking error: EVP_mdc2

2008-07-06 Thread Donn Cave
Quoth Ken Takusagawa [EMAIL PROTECTED]:

| $ ghc --make test-hopenssl.hs  -lcrypto
| [1 of 1] Compiling Main ( test-hopenssl.hs, test-hopenssl.o )
| Linking test-hopenssl ...
| /tmp/ken/lib/hopenssl-1.0/ghc-6.8.2/libHShopenssl-1.0.a(Digest.o): In
| function `s2O8_info':
| (.text+0xf3a): undefined reference to `EVP_mdc2'
| /tmp/ken/lib/hopenssl-1.0/ghc-6.8.2/libHShopenssl-1.0.a(Digest.o): In
| function `s2TQ_info':
| (.text+0x1435): undefined reference to `EVP_mdc2'
| collect2: ld returned 1 exit status

I see the following in the Configure file for openssl-0.9.8h:

  my $default_depflags = -DOPENSSL_NO_CAMELLIA -DOPENSSL_NO_CMS 
-DOPENSSL_NO_GMP -DOPENSSL_NO_MDC2 -DOPENSSL_NO_RC5 -DOPENSSL_NO_RFC3779 
-DOPENSSL_NO_SEED -DOPENSSL_NO_TLSEXT ;my $default_depflags = 
-DOPENSSL_NO_CAMELLIA -DOPENSSL_NO_CMS -DOPENSSL_NO_GMP 

I don't know why this would be, but I infer that the function hopenssl
was looking for is commonly missing in SSL builds.

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