Re: [Haskell-cafe] German names for kinds and sorts

2011-11-12 Thread Matthias Reisner

Am 12.11.2011 17:05 schrieb Robert Clausecker:

Hi all!

I want to write my Facharbeit (kind of an essay you have to write on a
specific topic you can choose yourself for highschool graduation) about
the type-system of Haskell. It is required in our school to write this
document in German language.

Most time, it is not really difficult to find an appropriate term for
concepts of Haskell, like types (Typen) or type classes (Typklassen).
But I really don't know how to call kinds and sorts in German. Any
ideas?

Yours, Robert Clausecker


Hi,

there was a thread on the translation of the word "kind" [1] some years 
ago, have a look at this. I'm not exactly sure what a sort is so I can't 
help with that. Maybe just "Sorte"?


Best wishes,
Matthias


[1] http://www.mail-archive.com/haskell@haskell.org/msg16752.html

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


Re: [Haskell-cafe] Problem with System.Timeout in Windows

2010-08-05 Thread Matthias Reisner

Am 05.08.2010 07:35 schrieb Adolfo Builes:

Hi All:

I have been trying to use System.timeout in windows, but for some
reason it doesn't work, a concrete example is:

import Network.HTTP
import System.Timeout

main = do
  rsp <- timeout 1000  $ simpleHTTP $ getRequest "http://10.1.2.3";
  case rsp of
Just rsp -> print $ show  rsp
Nothing  -> error "Nothing"

In this case I would expect to receive "Nothing" after 10 seconds, but
it ignores the timeout function.


Hi Adolfo,

the same behaviour for me with GHC 6.10.4 on Windows XP. If I set the 
timeout value to 0, I get


   *** Exception: Nothing

immediately. Any other value results in

   *** Exception: connect: failed (Connection timed out (WSAETIMEDOUT))

after about 20 seconds. I don't know where the problem is, but I have 
similar problems with the threadDelay function. There must be something 
broken somewhere for some windows systems.



Regards,

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


Re: [Haskell-cafe] Sockets get bound to wrong port on Windows

2010-06-03 Thread Matthias Reisner

Am 03.06.2010 08:05 schrieb Ketil Malde:

Antoine Latter  writes:

  

  *Main> PortNum 
  47138
  


  

The PortNum constructor should rarely be used directly



So, shouldn't the constructor be hidden, and exported from an .Internal
module? 

  

- it contains the port number in network-order. You should try:



Or perhaps even better, the type could be:

data PortNum = PortNum { msb, lsb :: Word8 }

so that we avoid this kind of confusion?

-k
  


Hi,

since this is really not obvious, I'd second to hide the constructor or 
at least a note should be added to the docs how to use PortNumber correctly.



Regards,

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


Re: [Haskell-cafe] Re: Sockets get bound to wrong port on Windows

2010-06-03 Thread Matthias Reisner

Am 03.06.2010 07:34 schrieb Bardur Arantsson:

On 2010-06-03 05:10, Matthias Reisner wrote:

Hi,

there's something wrong with port numbers in the Network.Socket module
of package network. Printing values gives:

*Main> PortNum 
47138
*Main> PortNum 47138




Try

   (fromIntegral ) :: PortNumber

(Yes, it's weird.)

Cheers,

Bardur

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



Hi Bardur,

indeed, this is weird. Thanks for the hint!


Regards,

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


Re: [Haskell-cafe] Sockets get bound to wrong port on Windows

2010-06-02 Thread Matthias Reisner

Am 03.06.2010 05:20 schrieb Ivan Miljenovic:

So I thought it's just an error in the show instance of PortNumber, which
shows the bytes flipped. But if I use the following code snippet

  sock <- socket AF_INET Datagram 0
  bindSocket sock $ SockAddrInet (PortNum ) iNADDR_ANY

to bind a socket to port , netstat and TCPView reveal that the socket is
actually bound to the wrong port 47138. I'm using network-2.2.1.7 on Windows
XP. Is that a bug or am I doing something wrong here?


Tried testing this as well; not sure how to test if the binding worked
but "netstat --numeric-ports" didn't contain  or 47138.


Hi Ivan,

here's a complete program to reproduce the error:

   module Main (main) where
   import Network.Socket

   main :: IO ()
   main = withSocketsDo $ do
   sock <- socket AF_INET Datagram 0
   bindSocket sock $ SockAddrInet (PortNum ) iNADDR_ANY
   recvFrom sock 65535
   return ()

The output of netstat/TCPView after starting the program is:

   MinSocketBind.exe:2724UDPPC1:47138*:*

By the way, I'm using GHC 6.10.4, which I think shouldn't make a difference.


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


[Haskell-cafe] Sockets get bound to wrong port on Windows

2010-06-02 Thread Matthias Reisner

Hi,

there's something wrong with port numbers in the Network.Socket module 
of package network. Printing values gives:


   *Main> PortNum 
   47138
   *Main> PortNum 47138
   

So I thought it's just an error in the show instance of PortNumber, 
which shows the bytes flipped. But if I use the following code snippet


   sock <- socket AF_INET Datagram 0
   bindSocket sock $ SockAddrInet (PortNum ) iNADDR_ANY

to bind a socket to port , netstat and TCPView reveal that the 
socket is actually bound to the wrong port 47138. I'm using 
network-2.2.1.7 on Windows XP. Is that a bug or am I doing something 
wrong here?



Regards,

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


Re: [Haskell-cafe] ANNOUNCE: Bravo-0.1.0

2010-03-23 Thread Matthias Reisner

Am 12.03.2010 05:37 schrieb Matthias Reisner:

Hi Michael

Am 12.03.2010 01:33 schrieb Michael Snoyman:
I'll need to look into the library a bit more to get a better idea, 
but it
seems like Bravo could work for my needs. One thing that concerns me 
is your
comment that it allows embedding of Haskell expressions. In general, 
I try
to keep a strict separation between login and presentation: can you 
explain

exactly what type of expressions can be embedded?


This is really one disadvantage of the current Bravo version I'm 
worrying about too. At the moment you can insert arbitrary Haskell 
expressions, so no one prevents the template writer from inserting 
expressions like `unsafePerformIO launchAtomicMissile >> return ""'. 
Some kind of security mechanism will definitely be included in future 
releases, but I'm not sure in what way at the moment. I thought about 
passing a list of permitted function names to the template creation 
function and then failing with an error if any other functions are used.


Today I thought about a security mechanism for Bravo and came to the 
simple solution: There actually is no need for it! If you don't trust 
your template writers, just do the following: Create a new module and 
import all functions you permit to be used in your templates (or hide 
functions from the Prelude). Call the template creation functions within 
this module and export all created data structures. Perhaps different 
templates may access different sets of permitted functions, so just 
create a module for each of these sets.


Meanwhile I created the wiki page for Bravo and added an example that 
illustrates the problem (see 
http://www.haskell.org/haskellwiki/Bravo#Security_concerns).




Finally, I can't seem to get it to compile on 6.12. Any chance of 
getting a

version out that supports it?


The problem seems to be haskell-src-meta, that doesn't like 
template-haskell-2.4, and on the other side I can't get build 
template-haskell < 2.4 with GHC-6.12. So I will contact Matt Morrow, 
the maintainer of haskell-src-meta, and see if he can fix it.


Matt didn't reply yet, but there already is a patched haskell-src-meta 
version available at http://moonpatio.com/repos/haskell-src-meta_NEW_TH. 
I updated Bravo to be compatible with this version.



Regards,

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


Re: [Haskell-cafe] Alternative dependencies in Cabal file

2010-03-17 Thread Matthias Reisner
Thanks, I missed that the flags are set dynamically if a dependency 
cannot be satisfied.



Am 17.03.2010 13:23 schrieb Daniel Fischer:

Am Mittwoch 17 März 2010 12:11:53 schrieb Matthias Reisner:

Hi,

for a package I need to ensure the user uses a certain package
configuration. So how would I rewrite the following pseudo-cabal
description?

Build-Depends: packageA < X,   packageB < Y
 or
   packageA >= X && < X',  packageB >= Y && < Y'
 or
   packageA >= X', packageB >= Y'

Build-Depends: ... common dependencies ...

where neither A nor B is the base package. Maybe I have to use if/else
blocks, but I don't know what conditions to use then.


Read http://www.haskell.org/ghc/docs/latest/html/Cabal/authors.html for a 
general description of what you can do, I'd try something like in

http://hackage.haskell.org/packages/archive/cabal-install/0.8.0/cabal-
install.cabal

flag oldAB
description: ancient packages A and B
default: False

flag newAB
description: shiny new A and B

Library blubb
build-depends:
common,
libraries
if flag(newAB)
build-depends: packageA >= X', packageB >= Y'
else if flag(oldAB)
build-depends: packageA < X, packageB < Y
else
build-depends: packageA >= X && < X', packageB >= Y && < Y'

If I remember correctly, that tries first to build against the new A and B, 
that failing, it sets flag newAB to false and tries again, first with the 
not-so-ancient A and B, hopefully (but I'm not sure about the order in 
which flags are toggled if the defaults don't give a successful install 
plan).




Regards,

Matthias

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


[Haskell-cafe] Alternative dependencies in Cabal file

2010-03-17 Thread Matthias Reisner

Hi,

for a package I need to ensure the user uses a certain package 
configuration. So how would I rewrite the following pseudo-cabal 
description?


   Build-Depends: packageA < X,   packageB < Y
or
  packageA >= X && < X',  packageB >= Y && < Y'
or
  packageA >= X', packageB >= Y'

   Build-Depends: ... common dependencies ...

where neither A nor B is the base package. Maybe I have to use if/else 
blocks, but I don't know what conditions to use then.



Regards,

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


Re: [Haskell-cafe] ANNOUNCE: Bravo-0.1.0

2010-03-11 Thread Matthias Reisner

Hi Michael

Am 12.03.2010 01:33 schrieb Michael Snoyman:

I'll need to look into the library a bit more to get a better idea, but it
seems like Bravo could work for my needs. One thing that concerns me is your
comment that it allows embedding of Haskell expressions. In general, I try
to keep a strict separation between login and presentation: can you explain
exactly what type of expressions can be embedded?


This is really one disadvantage of the current Bravo version I'm 
worrying about too. At the moment you can insert arbitrary Haskell 
expressions, so no one prevents the template writer from inserting 
expressions like `unsafePerformIO launchAtomicMissile >> return ""'. 
Some kind of security mechanism will definitely be included in future 
releases, but I'm not sure in what way at the moment. I thought about 
passing a list of permitted function names to the template creation 
function and then failing with an error if any other functions are used.



Also, while looking through the example, it looks like the library is making
some automatic translations, like firstName -> userFirstName and user ->
users. I've found these kinds of mappings to be brittle in the past; can you
explain how this is done (or if I'm simply missing something obvious)?


Bravo creates a data type per template, where the default naming scheme 
for the data type/constructor name is "name" -> "TplName". For each 
template variable a record field is created; for a template "temp" and a 
variable "var" the name will be "tempVar". Have a look at the 
`mkTemplatesWithOptions' and `mkTemplatesFromFileWithOptions' functions, 
that allow you to customize this naming scheme.



Finally, I can't seem to get it to compile on 6.12. Any chance of getting a
version out that supports it?


The problem seems to be haskell-src-meta, that doesn't like 
template-haskell-2.4, and on the other side I can't get build 
template-haskell < 2.4 with GHC-6.12. So I will contact Matt Morrow, the 
maintainer of haskell-src-meta, and see if he can fix it.



Regards,

Matthias




Thanks,
Michael

On Wed, Mar 10, 2010 at 8:46 PM, Matthias Reisner <
matthias.reis...@googlemail.com> wrote:


Hello,

I'm pleased to announce the first release of Bravo, a static text template
generation library, on Hackage: http://hackage.haskell.org/package/Bravo.

Bravo is a text template library that provides parsing and generation of
templates at compile time. Templates can be read from strings or files and
for each a new record data type is created, allowing convenient access to
all template variables in a type-safe manner. Since all templates are
processed at compile time, no extra file access or error handling at runtime
is necessary.

Bravo is inspired by the PHP template engine Smarty and the Haskell
template library chunks. Compared to chunks, Bravo provides additional
features like conditional template evaluation, embedding of Haskell
expressions and customized data type generation. I'm going to add further
information to the HaskellWiki page (
http://www.haskell.org/haskellwiki/Bravo) later.

Bravo is still highly experimental and not well-tested, so bug reports and
additional feedback are very welcome. I'd also like to hear if you feel the
package dependencies are to restrictive.


Regards,

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


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


Re: [Haskell-cafe] Re: ANNOUNCE: Bravo-0.1.0

2010-03-11 Thread Matthias Reisner

Am 11.03.2010 23:38 schrieb Simon Michael:

Thank you, how does it compare to HStringTemplate ?



Hi Simon,

I never worked with HStringTemplate, so as far as I can tell after 
having a glance at the HStringTemplate API and the wiki page, the main 
difference is that Bravo parses the templates at compile time, while 
HStringTemplate does at runtime. Besides that, HStringTemplate provides 
several methods for rendering different data types in different styles. 
This can also be accomplished in Bravo by writing the appropriate 
rendering function in your Haskell code and using it in the template.



Regards,

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


[Haskell-cafe] Re: [Haskell] ANNOUNCE: Bravo-0.1.0

2010-03-11 Thread Matthias Reisner

Hi Marc,

I'm sorry, the current Bravo version does not support caching of 
evaluated templates. Maybe this will be a feature of later releases.



Matthias


Am 11.03.2010 10:02 schrieb Marc Weber:

Hi Matthias,

  
Bravo is inspired by the PHP template engine Smarty and the Haskell 


Smarty is also about caching. Can you say whether your library support
kind of caching as well?

Marc Weber
  


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


[Haskell-cafe] ANNOUNCE: Bravo-0.1.0

2010-03-10 Thread Matthias Reisner

Hello,

I'm pleased to announce the first release of Bravo, a static text 
template generation library, on Hackage: 
http://hackage.haskell.org/package/Bravo.


Bravo is a text template library that provides parsing and generation of 
templates at compile time. Templates can be read from strings or files 
and for each a new record data type is created, allowing convenient 
access to all template variables in a type-safe manner. Since all 
templates are processed at compile time, no extra file access or error 
handling at runtime is necessary.


Bravo is inspired by the PHP template engine Smarty and the Haskell 
template library chunks. Compared to chunks, Bravo provides additional 
features like conditional template evaluation, embedding of Haskell 
expressions and customized data type generation. I'm going to add 
further information to the HaskellWiki page 
(http://www.haskell.org/haskellwiki/Bravo) later.


Bravo is still highly experimental and not well-tested, so bug reports 
and additional feedback are very welcome. I'd also like to hear if you 
feel the package dependencies are to restrictive.



Regards,

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