[Haskell-cafe] better error message for "undefined"
the haskell prelude introduces the type undefined and contains a remark to the effect that compilers are expected to intrudocue a meaningful error message. GHC just prints 'Prelude undefined' which is not very informativ. is there a way to have different kinds of undefined? such that i get a message which one was hit. something like writing in the code 'unefined 'my error 123' which prints 'undefined - my error 123' when it is accidentally hit. i searched the web, but found nothing. any suggestions? thanks a lot! andrew ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] retrieving arguments for functions from a heterogenous list (HList)
I have a number of functions which have some arguments and produce a single result. all the arguments are in a heterogenous list and the results should update the list. this appears somewhat similar to the keyword-argument solution for functions proposed by oleg kiselyov in 2004. i would like to have a method to convert the functions f :: A -> B -> C g:: A -> D -> C -> B(for example) to f' :: argTypes -> H -> H g' :: argTypes -> H -> H where H is a heterogenous list containing A, B, C, D (and others) and argTypes is another heterogenous list containing the types of the arguments, which are used to retrieve the data from the list (with .!!.) - the result has the correct type and is updated in the list with .@@. . naively this could be done by some functins fx (recursing over the list of arguments) storing the last argument in the HList: fx :: (HList l) => op -> HCons e l -> H -> H fx op HNil uod = uod .@@. op fx op (HCons a as) uod = fx (op arg) as uod where arg = uod .!!. a this code does not compile, because HNil and HCons do not match (they are different data types, not a union type). code that compiles looks like class (HList l, HList k , HUpdateAtHNat n e k k, HType2HNat e k n , HLookupByHNat n k e ) => HCall e n f l k | l k -> n where hcall :: f -> l -> k -> k -- not general instance ( HNat n , HUpdateAtHNat n e UoD UoD, HType2HNat e UoD n , HLookupByHNat n UoD e ) => HCall e n e HNil UoD where hcall opv HNil k = hcall0 opv k instance (HCall e n f l UoD , HLookupByHNat n UoD e, HType2HNat e n UoD ) => HCall e n (e -> f) (HCons a l) UoD where hcall op (HCons a l) k = hcall (op arg) l k where arg = hLookupByHNat n k n = hType2HNat (toProxy arg) k :: n hcall0 :: ( HUpdateAtHNat n f UoD UoD, HType2HNat f H n, HCall e n f HNil UoD) => f -> H -> H hcall0 op k = hUpdateAtHNat n (const op undefined) k `asTypeOf` k where n = hType2HNat (toProxy op) k where i factored out the terminating call, which is probably wrong. i would like to use it as: showPop4 :: (HList hNil, HCall Population n (District -> Population) (hConst District hNil) UoD) => (hCons District hNil) -> UoD -> UoD showPop4 arg uod = hcall showPop2 arg uod unfortunately, calls to this function result in 'cannot deduce' compilation error; it seems that some of the intermediate types are not known. i appreciate any help! andrew ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] dsl and gui toolkit
writing a gui is a mess (independent of wx or gtk) - too much detail is shown and not enough abstraction is done. haskell can help. i have written an experimental way of producing the GUI automatically with a description of the semantics of the types and operations involved (a la ontology, evnetually comparable what protege produces). the input is a descriptionof the entity ypes, the fields used, the functional dependencies between the fiels, plus the operations used. the division in screens and their layout. the rest ist automatic. the result is a GUI (with preferably gtk but i had also a wx version running). the ideas were inspired by eliot conal's work and wxgeneric, which seemed for administrative applications either too restricted or to specific. if somebody wants to try it out for his application, please write fr...@geoinfo.tuwien.ac.at (there is not much documentation and the code is not yet completely clean - testing by somebody else would be very valuable!) andrew ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] dsl and gui toolkit
thanks for the connection to the gui runner - it is interesting and worthwile, but a different approach. my approach is strictly declarative and does not describe sequences of process. it describes screens and links operations to buttons. then it takes inputs from the screen and runs the operations and posts the result on the screen. some operations open new screens etc. i started with the idea that ontologies describe the semantics of data in a static way; this should be (nearly) enough to create the user interface - which is all about semantics of the data. of course, you have to include in the ontology the semantics of the operations (as class with functions). the implementation is close to a reactive framework - adding a representation of all what is visible on the screen (the universer of discourse) in a format usable by the operations. then you have only to connect this 'universe of discourse' to the programs which operate on the data and post their reaction in the UoD and map the UoD to the screen the details are messy as i attempted to construct the internal data structures etc. as automatically as possible and with minimal designer input I did not use template haskell, yet, but will need to (i think). i am happy to share it with interested parties and hear the comments and perhaps somebody can help me with using templates to reduce the . it is IMHO not yet ready for posting in a library - but this is certainly the goal. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] how to determine the dependency versions before packaging and submitting to hackage
i plan to submit a package to hackage. i run it on my machine with a cabal file which has for all dependencies "any" (except for base, where it says >=4.0 -- see previous discussion on haskell-cafe). i am not certain, if my code runs agains any version, but i fear it is too restrictive to say >= "current version", which could exclude too much? testing against all previous versions of the packages seems complicated and very time consuming. what is the advice in this case? thank you andrew ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] graphics Windows Programming
There are several graphics packages to select from... But which one is the easiest to work with for students for a ghci - windows environment. I sense that cairo / gtk2hs does not support ghci. >From the HOpenGL home page I cannot find out what I would need to download for a windows environment (can somebody point me to the right direction?). We have used SOE under hugs but I sense it is not working with ghci? We found it also somewhat deficient for graphics beyond the content of the book - has it been extended and improved? Any advice greatly appreciated! Andrew Frank ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Proposal for restructuring Number classes
there has been discussions on and off indicating problems with the structure of the number classes in the prelude. i have found a discussion paper by mechveliani but i have not found a concrete proposal on the haskell' list of tickets. i hope i can advance the process by making a concrete proposal for which i attach Haskell code and a pdf giving the rational can be found at ftp://ftp.geoinfo.tuwien.ac.at/frank/numbersPrelude_v1.pdf if i have not found other contributions, i am sorry and hope to hear about them. i try a conservative structure, which is more conservative than the structure we have used here for several years (or mechveliani's proposal). It suggests classes for units (Zeros, Ones) and CommGroup (for +, -), OrdGroup (for abs and difference), CommRing (for *, sqr), EuclideanRing (for gdc, lcm, quot, rem, div...) and Field (for /). I think the proposed structure could be a foundation for mathematically strict approaches (like mechveliani's) but still be acceptable to 'ordinary users'. i put this proposal for discussion here and hope for suggestions how it can be improved before i put it to haskell'! andrew frank Numbers.hs Description: Binary data ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: [Haskell-cafe] Proposal for restructuring Number classes
i am most grateful to henning and dylan for their effort in restructuring the number classes. there seems to be agreement, that the current classes are not optimal. the decision what goes in a class depends enormously on what axioms one is assuming for an operation symbol. should * always be commutative or is its use for non-commutative types acceptable? i will now make an effort to use the proposed classes by dylan and hennig and adapt my code to it and then come back and report how it suited my needs. thank you for the help! andrew frank ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: [Haskell-cafe] recursive matrix computations
it appears possible to define matrix operations like LU-decomposition, SVD, inverse etc. in a recursive fashion (see transpose in the prelude). is this possible? has anybody code in haskell which does this (not asking for high performance here, more instructive value). thank you! andrew ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] duplicate symbols for ODBC-1.1.4.4 when running with GHCi
when i run a program (which works with GHC) under GHCi (in eclipse with FP support) then i get GHCi linker duplicate definition for symbol _sqlSucceeded whilst processing HSHDBC-odbc-1.1.4.4.o what is wrong here? any suggestion what i can change? thank you andrew ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] duplicate symbols for ODBC-1.1.4.4 when running with GHCi
additional information - the problem occurs only under windows (with ghc 6.8.3), not under linux (ubuntu) - with ghc 6.8.2 with linux (ghc 6.8.2) it executes under ghci. On Sun, 2008-08-17 at 12:21 +0200, Andrew U. Frank wrote: > when i run a program (which works with GHC) under GHCi (in eclipse with > FP support) then i get > > GHCi linker > duplicate definition for symbol _sqlSucceeded > whilst processing HSHDBC-odbc-1.1.4.4.o > > what is wrong here? any suggestion what i can change? > > thank you > andrew > > > ___ > 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] missingH 0.18.6 - problems with cabal configure
when i run cabal i get an error message: :~/haskellSources/packages/MissingH-0.18.6$ runhaskell Setup configure Setup.hs:19:35: Couldn't match expected type `(Either GenericPackageDescription PackageDescription, HookedBuildInfo)' against inferred type `PackageDescription' In the first argument of `(confHook defaultUserHooks)', namely `mydescrip' In the expression: let mydescrip = case os of "mingw32" -> ... _ -> ... in (confHook defaultUserHooks) mydescrip flags In the definition of `customConfHook': customConfHook descrip flags = let mydescrip = ... in (confHook defaultUserHooks) mydescrip flags what is wrong? i use ghc 6.8.2 and cabal 1.2.3.0 thanks for help! andrew ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] problem with cabal for syb-with-class
i tried to install wxGeneric and need syb-with-class. i got the package from hackage. configure runs fine, but when i build i get: Data/Generics/SYB/WithClass/Instances.hs:11:7: Could not find module `Data.Array': it is a member of package array-0.1.0.0, which is hidden but array-0.1.0.0 is installed, as shown later. what can be wrong? why is an installed package complained about as hidden? thanks for help! andrew [EMAIL PROTECTED]:~/haskellSources/packages/syb-with-class-0.3$ ghc-pkg describe array name: array version: 0.1.0.0 license: BSD3 copyright: maintainer: [EMAIL PROTECTED] stability: homepage: package-url: description: This package defines the classes @IArray@ of immutable arrays and @MArray@ of arrays mutable within appropriate monads, as well as some instances of these classes. category: author: exposed: True exposed-modules: Data.Array Data.Array.Base Data.Array.Diff Data.Array.IArray Data.Array.IO Data.Array.MArray Data.Array.ST Data.Array.Storable Data.Array.Unboxed hidden-modules: Data.Array.IO.Internals import-dirs: /usr/lib/ghc-6.8.2/lib/array-0.1.0.0 library-dirs: /usr/lib/ghc-6.8.2/lib/array-0.1.0.0 hs-libraries: HSarray-0.1.0.0 extra-libraries: extra-ghci-libraries: include-dirs: includes: depends: base-3.0.1.0 hugs-options: cc-options: ld-options: framework-dirs: frameworks: haddock-interfaces: /usr/share/doc/ghc6-doc/libraries/array/array.haddock haddock-html: /usr/share/doc/ghc6-doc/libraries/array f ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: problem with cabal for syb-with-class
in fairness, i have to add that i did inadvertetly install version 0.3. of syb-with-class and got the error i still cannot understand. installing version 0.4 did work flawlessly! nevertheless, i would be interested to understand the problem i encountered. andrew On Mon, 2008-08-25 at 18:08 +0200, Andrew U. Frank wrote: > i tried to install wxGeneric and need syb-with-class. > i got the package from hackage. > configure runs fine, but when i build i get: > > Data/Generics/SYB/WithClass/Instances.hs:11:7: > Could not find module `Data.Array': > it is a member of package array-0.1.0.0, which is hidden > > but array-0.1.0.0 is installed, as shown later. > what can be wrong? why is an installed package complained about as > hidden? > > thanks for help! > > andrew > > [EMAIL PROTECTED]:~/haskellSources/packages/syb-with-class-0.3$ ghc-pkg > describe array > name: array > version: 0.1.0.0 > license: BSD3 > copyright: > maintainer: [EMAIL PROTECTED] > stability: > homepage: > package-url: > description: This package defines the classes @IArray@ of immutable > arrays and > @MArray@ of arrays mutable within appropriate monads, as > well as > some instances of these classes. > category: > author: > exposed: True > exposed-modules: Data.Array Data.Array.Base Data.Array.Diff > Data.Array.IArray Data.Array.IO Data.Array.MArray > Data.Array.ST > Data.Array.Storable Data.Array.Unboxed > hidden-modules: Data.Array.IO.Internals > import-dirs: /usr/lib/ghc-6.8.2/lib/array-0.1.0.0 > library-dirs: /usr/lib/ghc-6.8.2/lib/array-0.1.0.0 > hs-libraries: HSarray-0.1.0.0 > extra-libraries: > extra-ghci-libraries: > include-dirs: > includes: > depends: base-3.0.1.0 > hugs-options: > cc-options: > ld-options: > framework-dirs: > frameworks: > haddock-interfaces: /usr/share/doc/ghc6-doc/libraries/array/array.haddock > haddock-html: /usr/share/doc/ghc6-doc/libraries/array > f > ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: problem with cabal for syb-with-class
thank you very much for the explanation! i take that in this case, the error is in the cabal, which does not list the required package. andrew On Tue, 2008-08-26 at 15:09 +0100, Duncan Coutts wrote: > On Tue, 2008-08-26 at 14:30 +0100, Dougal Stanton wrote: > > On Tue, Aug 26, 2008 at 2:22 PM, Duncan Coutts > > <[EMAIL PROTECTED]> wrote: > > > > > So when ghc finds that one of your modules needs to import something > > > that is not in one of the given packages it says that it's in another > > > package that is 'hidden'. Of course it's only hidden because Cabal told > > > ghc to hide them. > > > > Yes, it is one of those unfortunate error messages that says "I know > > what the problem is *and* how to fix it, but I'm not going to". ;-) > > Actually it's more like: "I know what the problem is but I cannot fix > it. He knows how to fix it, but doesn't know there's a problem!" :-) > > GHC knows what the problem is but it's just following orders. Cabal gave > the orders but doesn't know there is a problem. > > That's why it'll be fixed when Cabal does the dep chasing rather than > delegating that to ghc --make. Cabal will then be able to either just > pull in the (probably) right packages, or report the problem using the > language of the problem domain and not the implementation. > > Duncan > ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] best runProcess solution to work with windows and linux
i use System.POSIX.IO to run a process and access the handles (after due transformation) to get the values back. this solution is unfortunately not portable and works only on unix (or cygwin) but not for plain windows. there seems to be a somewhat comparable package in system.win32.process. is there a solution independent of OS? what is the best approach to use to run a process and read the result back which works in both unix and windows? any suggestion highly appreciated! andrew ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] couchDB
a few weeks ago a question was posed on this list for examples how to use couchDB. i post the 'hello world' for couchDB using the haskell interface - perhaps it helps other to start! a more extensive and complicate example is found at www.maztravel.com/haskell/mySqlToCouchDB.html I created with Futon a db names "first" (i had no luck with names containing a - or a _ , but have not investigated further). the runcouchDB' affects the couchDB at localhost. andrew ps: if there is a better place to document examples? a wiki on haskell.org would be nice and should be available for any project in hackage. {-# LANGUAGE DeriveDataTypeable #-} module Main ( ) where import Database.CouchDB import Data.Data (Typeable) import Text.JSON s1 = JSString $ toJSString "Peter" m1 = makeObj [("FirstName", s1), ("FamilytName", JSString . toJSString $ "Miller")] mydb1 = db "first"-- convert db name to checked couchdb -- problem with "-" or "_" in db names in haskell?? main = do putStrLn "start couchdb tests" (doc, rev) <- runCouchDB' $ newDoc mydb1 m1 -- works return () ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] subversion with haskell
hackage contains a package Hs2SVN HsSVN seems to do what i need, but unfortunately, i cannot install it - i have the error : checking for stdint.h... yes checking for unistd.h... yes checking svn_error.h usability... no checking svn_error.h presence... no checking for svn_error.h... no configure: error: SVN headers are required. Hint: EXTRA_CPPFLAGS cabal: Error: some packages failed to install: HsSVN-0.4.3 failed during the configure step. The exception was: ExitFailure 1 i installed all development packages i could see related to svn - which one is really needed? can you clarify and point me in the right direction? (and put the information in the package cabal file so it is copied to hackage) thank you andrew ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] packages on hackage: how to download files which are not included in the darcs inventory
i try to use jsmw. i see that there are multiple example files in a directory. this directory is not included in darcs and does not download automatically. is there an easy way to download directories (i can get the files individually with curl - but this is slow and errorprone)? help is appreciated! andrew ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] jswm - how to manipulate strings?
i try to use jswm to build some web applications, but i got quickly stuck. I used the example programs provided and tried to change them. starting with the calculator, i would like to use the string that the user puts in and apply a function to it (say transform it to capitals, later i want to do more complex operations). now i cannot find a way to apply a function to the type returned from the input: get'value :: (Monad mn, CHTMLTextAreaElement this) => Expression this -> mn (Expression String) how can i apply some function to the string in the input : mn (Expression String) ? or how can i get the string out such that i can change it and later put it back into an expression? help is appreciated - there seems to be only a small piece missing.. andrew ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: using Network.CGI
dear anders indeed, the example on your page works perfectly and mine now too! i did misunderstand something basic on how to use network.cgi. my wrong approach: 1. i copied the program from the web page (commented out the getinput:: line, which seems to be in error). 2. i run it with runghc and pasted the result into a web page; this page opens in the browser, but does not have actions. correct is to compile with ghc and copy the executable into the cgi-bin folder. then it works... i will put this hint somewhere in the web wiki. i think this limits what network.cgi can be used for: it will work only on systems, where the output from the ghc can execute. specifically, this means, i cannot move the executable to an android mobile phone and use it there (assuming that there is a web server, e.g. i-jetty, which understands cgi (does it?)). is this correct? i appreciated your quick reply - thank you for your help! andrew On Thu, 2010-08-05 at 18:31 -0400, Anders Kaseorg wrote: > On Thu, 5 Aug 2010, Andrew U. Frank wrote: > > which is clearly not producing the second part of the code, namely > > output a greeting. > > That’s what it’s supposed to output. Have you considered typing in a name > and submitting the form? It works fine for me: > <http://andersk.mit.edu/greet.cgi>. > > > i try to use the Network.CGI package from darcs. > > (Note also that the current version is maintained in Git, not Darcs, but > that’s a minor detail. See http://hackage.haskell.org/package/cgi .) > > Anders ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] couchdb - newView command
i use haskell couchdb 0.10 with more luck than others: it works for me quite well. I have been careful to convert to json strings separately from the calls to runCouchDB - so i could check that the values were correct. i sense there is a difficulty with 'newView' - it does not allow to update a viewset, but one has to select for each change a new viewset (design) name; which is sort of annoying. the newView operation should ptobably be called 'newViewset', because it sets multiple views in one design document. it would be nice, if that could not only be set, but also updated. (the full set at once) i would also recommend that the first parameter is of type DB and not String - or are there any particular reasons for this? i appreciate the package and i like it! andrew ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Deprecated gtk2hs functions
may i suggest that the description of the package, where it lists the depreciated functions, give also a hint, how the function should be replaced. i often hit the wall of depreciated functions when i try to use a packaged not having been compiled for a while and i have to replace the functions. then the searching starts... - if the information were included in the package description (automatically produced with haddock from a bit of text in the source code, written by somebody that did the change and has the information at his fingertips), it would save a lot of searching and failing upgrade experiences. gtk2hs is just a point in case, but it applies generally. any comments? andrew On Fri, 2010-07-16 at 17:44 -0400, Alex Rozenshteyn wrote: > More like buttonActivated [1]. > > > Has it been decided that button-specific events are going to be > deprecated in favor of their general widget equivalents, with > buttonActivated being an (IMO) awkward title for buttonClicked? > > > [1] > http://www.haskell.org/gtk2hs/docs/current/Graphics-UI-Gtk-Buttons-Button.html#v%3AbuttonActivated > > On Fri, Jul 16, 2010 at 3:20 PM, Thomas DuBuisson > wrote: > You mean something like buttonPressEvent [1]? > > > on button buttonPressEvent > > You can define signals, the constructor is exposed. > > > > [1] > > http://www.haskell.org/gtk2hs/docs/current/Graphics-UI-Gtk-Abstract-Widget.html#v%3AexposeEvent > > > > On Fri, Jul 16, 2010 at 11:36 AM, Alex Rozenshteyn > wrote: > > I recently started playing around with gtk2hs. > > I noticed that `onClicked`, `afterClicked`, etc. functions > have been > > deprecated, presumably in favor of the `on` and `after` > functions in the > > Glib signals module, but I couldn't find a collection of the > appropriate > > signals to replace the functionality. > > > > Am I simply being blind? > > > > -- > > Alex R > > > > > > ___ > > Haskell-Cafe mailing list > > Haskell-Cafe@haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > > > > > > -- > Alex R > > ___ > 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] phantom types for inheritance between types
there are packages which use phantom types to express inheritance (subtype) relations. unfortunately i cannot find a simple example and seem to misunderstand something. can somebody help with the following simple example? i have a most general type Dated, a subtype Note and a subsubtype Task. i have only instances for Note and Task, but operations for tasks and dated. my primary question is: why should i have the contexts in the classes (the code compiles without them)? they do not say more than what is already expressed in the instance declarations. i do also not think that i have used phantom types properly (eg. gtk2hs uses phantom types differently). what would be the proper solution? would it work for cases with multiple inheritance? thank you! andrew class CDated a class CDated a => CNotes a class CNotes a => CTasks a instance CDated Task instance CDated Note instance CNotes Note instance CNotes Task instance CTasks Task class Dated n where datedop :: n -> n class Notes1 n where noteop :: n -> n class Tasks1 n where taskop :: n -> n data Note = Note Int data Task = Task Int instance CTasks x => Tasks1 x where taskop n = n instance CDated x => Dated x where datedop n = n t:: Task = Task 1 n :: Note = Note 1 tt = taskop t -- nt = taskop n -- compiler error -- as expected! tx = datedop t nx = datedop n ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] creating a type based on a string
I have a user input (string) and need to select one of two types. depending what the input is. is this possible? data A data B data X n = X String op :: String -> X n op "a" = X "a" :: X A op "b" = X "b" :: X B this does obviously not compile. is there a way to achieve that the type X A is produced when the input is "a" and X B when the input is "b"? thank you for help! andrew ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] wiki in hackage
i think to add a wiki to each package is a great idea. as a default, it could be started automatically by uploading to hackage and filled with the readme.txt file (if availble) in the tar uploaded. if it is empty and exist, it is a point to check for when a package does not install immediately. alternatively, one has to search the web to see if there is some place with notices about this package. i would have loved to see wiki's for packages to post my result of work- arounds for problems with dependencies, small changes in source code etc. that could be posted there till the maintainer finds time to produce a new version. great idea! andrew frank ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] problem with editline install
i tried to install editline (because i wanted to install djinn, which depends on it): with cabal install and with downloading and runghc Setup.lhs configure i got the same error: checking for completion_matches... no configure: error: editline not found, so this package cannot be built See `config.log' for more details. in the log i did not see anything helpful (at my level of understanding). i could then install with synaptic because a deb package existed for ubuntu). what did i wrong? thanks for helpful comments andrew ps. in this case a wiki would have been helpful. it would have been a less intruding form to communicate than sending an email to the developer. especially in the case i assume i made some error. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] haddock - 'could not find link destination"
i try to use haddock for documentation, but have no success. no output is produced. i assume i make some stupid mistake (not having used haddock before) help is appreciated! thank you andrew --- i get the following error: $ haddock Hadtest2.hs Warning: Main: could not find link destinations for: GHC.Types.Int GHC.Base.String Hadtest2.hs is a simplistic test program with some parts copied from the haddock manual: module Main (square, this) where -- | a constant this :: String this = "this" -- |The 'square' function squares an integer. square :: Int -> Int square x = x * x main = do putStrLn $ "test " ++ show (square 4) return () -- ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] haddock - error
the problem with me getting no haddock output whatsoever was that i had not reconfigured cabal after replacing haddock 2.4 by 2.5 (by installing it with cabal). it would be helpful if there were an error message - but i can clearly see that this is difficult to achieve in this case. thanks for the help! ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] classes with types which are wrapped in
i encounter often a problem when i have a class with some operations (say class X with push) applied to a type A b. I then wrap A in a type A_sup, with some more type parameters and i cannot write a instance of class A_sup because i have a kind mismatch. any suggestions? (reordering of the type parameters of A_sup is not a solution, because another class operates on this parameter) here a simplistic case (i know that A could be reduced to [], my real cases are more complicated). data A b = A b [b] data Asup x ab y = Asup x ab y class X a b where push :: b -> a b -> a b instance X A Int where push b' (A b bs) = A b' (b:bs) instance X Asup Char Int Float where push b' (Asup a b c) = Asup a (push b' b) c -- this does not compile because the number of type arguments for X is wrong. if i try with a type type A_2 b = Asup Char (A b) Float instance X A_2 Int where push b' (Asup a b c) = Asup a (push b' b) c (and --TypeSynonymInstances) i get: Type synonym `A_2' should have 1 argument, but has been given 0 In the instance declaration for `X A_2 Int' what is the solution? thank you! andrew ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: classes with types which are wrapped in
i thank for the two suggestions (newtype as a wrapper and type families) and i have explored them. haskell-cafe was very helpful! i use often a piece of code to update a part of a record with field names which codes as follows: data X a b c = X {afield :: a, bfield :: b, cfield :: c} dotoBfield :: (b -> b) -> X a b c -> X a b c dotoBfield op x = x { bfield = op (bfield x)} and similar for A and C. is there a better idiom to achieve the same effect? can this be automated (for example, using generics)? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] custom widgets
we used wx originally but switched to gtk. the great advantage is glade... which is very flexible and still you can add/change whatever you need to in gtk in your haskell code. we checked porting between linux (ubuntu) and windows (xp) and encountered no problems. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] gtk2hs gtkbuilder
i currently use gtk2hs with libglade (and glade). i understand that the gtkbuilder allows more constructs than libglade. how to use gtkbuilder in gtk2hs? i see that John Millikin has posted a patch for gtk2hs - but i cannot find it and no documentation for its use? can anyone point me to a patched version of gtk2hs and some examples? thank you! andrew ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] HLIst - how to use TIPTransform with functions that run in the IO monad?
i use the TIPTransform module that Oleg has provided - very nice and easy to use! Thank you Oleg!! now i run into a problem, i seem not to be able to resolve: how to use TIPTransform with functions that use the IO monad? considering the example tip5 in Olegs communiation, where he uses a function with three arguments from the TIP (HList) and producing a result in the HList. i would like to use a similar functionality, getting the arguments from the HList and producing a result which is again stored in the HList - but the function has a signature like f :: Int -> String -> IO String. the resulting string should go int the HList. i assume i need a function like ttip: ttipM :: op -> db -> IO db? can somebody help me with this? i appreciate any help! andrew ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] dependent types
in modeling real application we have often the case that the type of some object depends on a value. e.g. small_boat is a vessel with size less than a constant. big_boat is a vessel with a larger size. for example, many legal classifications are expressed in this form (e.g. car vs. truck) depending on the type, operations are applicable or not (e.g. road with restriction 'no trucks'). how could one model such situations in haskell? i assume there are several possibilities... ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe