Re: [Haskell-cafe] Dynamic and equality

2013-07-21 Thread Alberto G. Corona
You can define:

data EqDyn= forall a.(Typeable a, Eq a)= EqDyn a

instance Eq EqDyn where
(EqDyn x) == (EqDyn y)= typeOf x== typeOf y  x== unsafeCoerce y

unsafeCoerce is safe synce the expression assures that types are equal


2013/7/20 adam vogt vogt.a...@gmail.com

 On Sat, Jul 20, 2013 at 12:31 AM, Carter Schonwald
 carter.schonw...@gmail.com wrote:
  the tricky part then is to add support for other types.
 
  another approach to existentially package type classes with the data
 type!
 
  eg
  data HasEq  = forall a . HasEq ( Eq a = a)
  or its siblinng
  data HasEq a = Haseq (Eq a = a )
 
  note this requires more planning in how you structure your program, but
 is a
  much more pleasant approach than using dynamic when you can get it to
 suite
  your application needs.
 
  note its also late, so I've not type checked these examples ;)

 Hi Carter,

 It doesn't seem like the existential one will work as-is, since ghc
 rejects this:

 {-# LANGUAGE ExistentialQuantification #-}
 data HEQ = forall a. Eq a = HEQ a
 usingHEQ :: HEQ - HEQ - Bool
 usingHEQ (HEQ a) (HEQ b) = a == b


 I think you were hinting at this option which is better than my first
 suggestion:

 {-# LANGUAGE ExistentialQuantification #-}
 import Data.Typeable
 data DYN = forall a. Typeable a = DYN (a, DYN - Bool)

 mkDyn :: (Eq a, Typeable a) = a - DYN
 mkDyn x = DYN (x, \(DYN (y, eq2)) - case cast y of
 Just y' - x == y'
 _ - False)

 mkDyn' :: Typeable a = a - DYN
 mkDyn' x = DYN (x, \_ - False)

 eqDyn :: DYN - DYN - Bool
 eqDyn x@(DYN (_, fx)) y@(DYN (_,fy)) = fx y || fy x


 Maybe there's some way to get mkDyn' and mkDyn as the same function,
 without having to re-write all of the Eq instances as a 2-parameter
 class like http://www.haskell.org/haskellwiki/GHC/AdvancedOverlap.


 --
 Adam

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




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


[Haskell-cafe] Choosing an xml parser

2013-07-21 Thread L Corbijn
Hello Cafe,

I am trying to write a library to parse (and process) the OpenGL xml spec
into haskell values. The problem is that I don't know what xml library to
choose. So far I can think of the following requirements:

- Some error reporting, possibly warning for unparsed elements (as that
signals that the parser needs updating).
- Not too bulky for the not so simple registry schema [1].
- Preferably some way to preprocess some nodes (this could probably be done
by any xml library).
- Preferably not too memory hungry (the current spec is about 2MB)

Does somebody have a recommendation for a xml library to use for this?

Regards,
Lars

[1]:
https://cvs.khronos.org/svn/repos/ogl/trunk/doc/registry/public/api/registry.rnc
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] catching IO errors in a monad transformer stack

2013-07-21 Thread Arie Peterson
On Thursday 18 July 2013 23:05:33 Eric Rasmussen wrote:
 […]
 Would there be any interest in cleaning that up and adding it (or something
 similar) to Control.Monad.CatchIO?
 […]

MonadCatchIO-transformers is being deprecated, as recently GHC has removed the 
'block' and 'unblock' functions, rendering the api provided by 
Control.Monad.CatchIO obsolete.


Regards,

Arie


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


Re: [Haskell-cafe] Choosing an xml parser

2013-07-21 Thread Carlos López-Camey
Hi L, I have used TagSoup, it is fine and simple.

http://community.haskell.org/~ndm/tagsoup/


2013/7/21 L Corbijn aspergesoe...@gmail.com

 Hello Cafe,

 I am trying to write a library to parse (and process) the OpenGL xml spec
 into haskell values. The problem is that I don't know what xml library to
 choose. So far I can think of the following requirements:

 - Some error reporting, possibly warning for unparsed elements (as that
 signals that the parser needs updating).
 - Not too bulky for the not so simple registry schema [1].
 - Preferably some way to preprocess some nodes (this could probably be
 done by any xml library).
 - Preferably not too memory hungry (the current spec is about 2MB)

 Does somebody have a recommendation for a xml library to use for this?

 Regards,
 Lars

 [1]:
 https://cvs.khronos.org/svn/repos/ogl/trunk/doc/registry/public/api/registry.rnc

 ___
 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] [Haskell] [ANN] Initial release of the threepenny-gui library, version 0.1.0.0

2013-07-21 Thread Sergey Mironov
Hi, I have a Path problem when installing threepenny-gui from Hackage.
Probably somtething trivial.

Sergey


src/BarTab.hs:9:8:
Could not find module `Paths'
Use -v to see a list of the files searched for.
Failed to install threepenny-gui-0.1.0.0
cabal: Error: some packages failed to install:
threepenny-gui-0.1.0.0 failed during the building phase. The exception was:
ExitFailure 1



2013/7/21 Heinrich Apfelmus apfel...@quantentunnel.de:
 Dear Haskellers,

 And the shark, he has teeth,
 And he wears them in (his) face.
 And Macheath, he has a knife,
 (But) yes the knife, no-one sees.

 After an obligatory cryptical quotation from a famous writer, I am pleased
 to announce the first public release of *threepenny-gui*, a cheap and simple
 library to satisfy your immediate GUI needs in Haskell.

 Want to write a small GUI thing but forgot to sacrifice to the giant rubber
 duck in the sky before trying to install wxHaskell or Gtk2Hs? Then this
 library is for you!

 Threepenny-gui is easy to install (!!) because it uses the web browser as a
 display. Internally, we implement a small web server that communicates with
 the browser to display GUI elements. Consequently, you can use HTML and CSS
 to design the user interface. You can freely manipulate the HTML DOM and
 handle browser events by writing Haskell code.

   hackage  - http://hackage.haskell.org/package/threepenny-gui
   examples - https://github.com/HeinrichApfelmus/threepenny-gui#examples
   source   - https://github.com/HeinrichApfelmus/threepenny-gui

 Many thanks to Daniel Austin for collaborating with me on this project and
 to Chris Done for implementing the Ji library which is the basis for this
 effort.


 On that note, the threepenny API for creating and manipulating GUI elements
 departs from earlier traditions. Do you like the new look and feel of the
 API? What do you think could be improved? Try it out and send us your
 feedback!


 Best regards,
 Heinrich Apfelmus

 --
 http://apfelmus.nfshost.com


 ___
 Haskell mailing list
 hask...@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell

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


Re: [Haskell-cafe] catching IO errors in a monad transformer stack

2013-07-21 Thread Eric Rasmussen
Arie,

Thanks for calling that out. The most useful part for my case is the
MonadCatchIO implementation of catch:

catch :: Exception e = m a - (e - m a) - m a

Hoogle shows a few similar functions for that type signature, but they
won't work for the case of catching an IOException in an arbitrary monad.
Do you happen to know of another approach for catching IOExceptions and
throwing them in ErrorT?

Thanks,
Eric






On Sun, Jul 21, 2013 at 7:00 AM, Arie Peterson ar...@xs4all.nl wrote:

 On Thursday 18 July 2013 23:05:33 Eric Rasmussen wrote:
  […]
  Would there be any interest in cleaning that up and adding it (or
 something
  similar) to Control.Monad.CatchIO?
  […]

 MonadCatchIO-transformers is being deprecated, as recently GHC has removed
 the
 'block' and 'unblock' functions, rendering the api provided by
 Control.Monad.CatchIO obsolete.


 Regards,

 Arie


 ___
 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] [Haskell] [ANN] Initial release of the threepenny-gui library, version 0.1.0.0

2013-07-21 Thread Henning Thielemann


On Sun, 21 Jul 2013, Sergey Mironov wrote:


Hi, I have a Path problem when installing threepenny-gui from Hackage.
Probably somtething trivial.


I have written a small script cabal-upload that tries to compile a package 
before uploading it to Hackage. That helps to assert that all required 
files are registered in the cabal file.


http://hackage.haskell.org/package/cabal-scripts

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


Re: [Haskell-cafe] [Haskell] [ANN] Initial release of the threepenny-gui library, version 0.1.0.0

2013-07-21 Thread Heinrich Apfelmus

Henning Thielemann wrote:


On Sun, 21 Jul 2013, Sergey Mironov wrote:


Hi, I have a Path problem when installing threepenny-gui from Hackage.
Probably somtething trivial.


I have written a small script cabal-upload that tries to compile a 
package before uploading it to Hackage. That helps to assert that all 
required files are registered in the cabal file.


http://hackage.haskell.org/package/cabal-scripts


Nice! However, I can't find the  cabal-test  executable after installing 
your package?



Best regards,
Heinrich Apfelmus

--
http://apfelmus.nfshost.com


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


Re: [Haskell-cafe] Wrapping all fields of a data type in e.g. Maybe

2013-07-21 Thread Michael Orlitzky
On 07/20/2013 04:49 PM, adam vogt wrote:
 
 Hi Michael,
 
 It's fairly straightforward to generate the new data with template
 haskell [1], and on the same page, section 10.7 'generic' zipWith is
 likely to be similar to your merging code.
 
 [1] 
 http://www.haskell.org/haskellwiki/Template_Haskell#Generating_records_which_are_variations_of_existing_records
 

I don't know any TH yet, but this looks like it just might work. Thanks
for the suggestion!



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


Re: [Haskell-cafe] catching IO errors in a monad transformer stack

2013-07-21 Thread John Lato
I think most people use monad-control these days for catching exceptions in
monad stacks (http://hackage.haskell.org/package/monad-control-0.3.2.1).
 The very convenient lifted-base package (
http://hackage.haskell.org/package/lifted-base) depends on it and exports a
function Control.Exception.Lifted.catch:

Control.Exception.Lifted.catch :: (MonadBaseControl IO m, Exception e)
  = m a - (e - m a) - m a

I'd recommend you use that instead of MonadCatchIO.


On Mon, Jul 22, 2013 at 4:13 AM, Eric Rasmussen ericrasmus...@gmail.comwrote:

 Arie,

 Thanks for calling that out. The most useful part for my case is the
 MonadCatchIO implementation of catch:

 catch :: Exception e = m a - (e - m a) - m a

 Hoogle shows a few similar functions for that type signature, but they
 won't work for the case of catching an IOException in an arbitrary monad.
 Do you happen to know of another approach for catching IOExceptions and
 throwing them in ErrorT?

 Thanks,
 Eric






 On Sun, Jul 21, 2013 at 7:00 AM, Arie Peterson ar...@xs4all.nl wrote:

 On Thursday 18 July 2013 23:05:33 Eric Rasmussen wrote:
  […]
  Would there be any interest in cleaning that up and adding it (or
 something
  similar) to Control.Monad.CatchIO?
  […]

 MonadCatchIO-transformers is being deprecated, as recently GHC has
 removed the
 'block' and 'unblock' functions, rendering the api provided by
 Control.Monad.CatchIO obsolete.


 Regards,

 Arie


 ___
 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


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