Re: [Haskell-cafe] type class constraints headache
methods :: (Eq a) = [(String, a)] methods = [ (method1, undefined ) , (method2, undefined) ] enumerateMethodNames :: [String] enumerateMethodNames = map fst methods The above does not compile because the source does not have enough information for GHC to determine what actual types to use for methods since undefined can stand in as values for any type. The program will compile if you use actual values instead of undefined or supply an explicit type signature. for example: enumerateMethodNames = map fst (methods :: [(String, String)]) or methods :: [(String, SomeEqType)] Rahul ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] type class constraints headache
I am trying to understand the mechanism behind -- why does the first example compile and what constraints does enumerateMethodNames add on a (which it does not inspect)? enumerateMethodNames does not add on any constraints. If you don't actually use methods GHC does not care what it's type is but the moment you use it some place the compiler needs to infer it's type which it is unable to do in your case because the undefineds can be of any type. HTH Rahul ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Using Cabal during development
Okay, but have you ever felt the need to make in the same project a library and an executable which depends on this library (even just like me, for testing purpose)? How would you do it? Specifying the modules under test in other-modules section for the executable does the trick for me. I can email you a suitable elided cabal file for one of my projects if you want. Also another really helpful thing for testing is adding a .ghci file in your project I usually check in the .ghci with my source. Standard commands that I define in .ghci usually include :test to run the Test Suite. I also use .ghci set up the correct source paths and to start up with the test module loaded. So recompiles are usually just as simple as :reload. I still run the complete cabal configure -ftest cabal configure build ./dist//test before commits. Rahul ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Using Cabal during development
Then how does the 'Executable' section of your .cabal look like? That's what I can't get working. Suitably elided. Executable test hs-source-dirs: src, tests other-modules:Text.Yaml.Yay, Text.Yaml.Yay.Syck main-is: Main.hs build-depends:base, HsSyck, syb if flag(test) build-depends: QuickCheck = 2.1 2.2, test-framework-quickcheck2 = 0.2 0.3, test-framework = 0.2 0.3 else buildable: False Library Hs-Source-Dirs: src Exposed-Modules: Text.Yaml.Yay, Text.Yaml.Yay.Syck Other-Modules:Text.Yaml.Yay.Internal.Utils, Text.Yaml.Yay.Syck.Encoder, Text.Yaml.Yay.Syck.Decoder Build-Depends:base, HsSyck, syb if flag(test) -- Faster builds ghc-options:-O0 else -- Optimized builds ghc-options:-O2 if flag(nolib) buildable: False ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Stack ADT?
What's going on here? I'm not even calling function POP. *Data.Stack let s2 = pop s1 *Data.Stack top s2 *** Exception: Stack.hs:8:0-28: Non-exhaustive patterns in function pop Haskell being a non strict language, does not evaluate pop s1 when you define let s2 = pop s1. but when you try to use s2 by evaluating top s2 pop s1 needs to be evaluated leading to the error in pop, since the definition of pop, does not deal with the case when the Stack is empty (Stack []). pop (Stack (_:xs)) = Stack xs top (Stack (x:_)) = x ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Determining application directory
So, is there a way to get an application directory path under Windows? I remember that there is a way to do this using WinAPI, but how to do this Haskell? The System.Directory module has some methods to get specific directory names in an OS agnostic manner. The closest method that matches what you want is getAppUserDataDirectory which uses the windows API function SHGetFolderPath to get the folder for well known name. IIRC Windows supports a notion of Constant special item's and if getAppUserDataDirectory does not do what you want you can call SHGetFolderPath using the CSIDL you are interested in. The code to do so should be identical to the source for getAppUserDataDirectory CSIDL'a are listed here [1] Links. [1] http://msdn.microsoft.com/en-us/library/bb762494%28VS.85%29.a ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Windows emulator for testing purposes
Do you have any recommendations for a free/open source solution that would let me emulate a Windows environment for testing purposes? Sun's Virtual Box? - http://www.virtualbox.org/ You would still need a Windows license though. Cheers, Rahul ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] What's going on here?
*Main dropFirst [3 4 5 6] List members are separated by commas. Space in Haskell denotes function application. Hence the error message: Hence t No instance for (Num (t - t1 - t2 - Int)) arising from the literal `3' at interactive:1:11-17 Possible fix: add an instance declaration for (Num (t - t1 - t2 - Int)) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Generating random enums
OK, I think what you're saying is to work with (random) integers and use fromEnum and toEnum to get corresponding DayOfWeek. But I get this when I try to use toEnum: *Main toEnum 2 ghci does not know what type of enum you want to create from the number 2. Try: toEnum 2 :: DayOfWeek That said, I would expect toEnum 2 to give an error like: 'Ambiguous type variable `a''. So I am not sure why your error message says: '** Exception: Prelude.Enum.().toEnum: bad argument' ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Enum to String, and back?
On Wed, Apr 15, 2009 at 3:13 PM, michael rice nowg...@yahoo.com wrote: Using Show it is possible to establish a relationship between an enum type and a String type to display it. Can one as easily establish a reverse relationship, i.e., convert a String type like Red back to its corresponding Color type? Make it an instance of the Read type class. http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t%3ARead That will allow you to write - read Red :: Color = Red HTH Rahul ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Remote control of firefox through Haskell?
Selenium (http://selenium.openqa.org/) might do what you want. The bindings were announced on this list a little while ago (http://tinyurl.com/se-bindings) On Tue, Jul 15, 2008 at 3:12 PM, Jefferson Heard [EMAIL PROTECTED] wrote: Is there a library out there that will allow me to remote-control the firefox or mozilla browsers, e.g. change the current page, open a new tab? -- I try to take things like a crow; war and chaos don't always ruin a picnic, they just mean you have to be careful what you swallow. -- Jessica Edwards ___ 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] where to put handy functions?
On 8/9/07, Chad Scherrer [EMAIL PROTECTED] wrote: Is there process for submitting functions for consideration for inclusion into future versions of the standard libraries? For example, I'd like to see this in Data.List: I imagine including it in std lib takes a while. Would it be a good idea to include it in MissingH http://software.complete.org/missingh in the mean time? Cheers, Rahul ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Using HList Records
Using The Darcs version of HList (http://darcs.haskell.org/HList/), I can do simple things with (H)lists just fine, so --angus = Key 42 -- .*. Name Angus -- .*. Cow -- .*. Price 75.5 -- .*. HNil --main = putStrLn (show angus) works, On the other hand examples from the HList paper for extensible records like --key = firstLabel FootNMouth key --name = nextLabel keyname --breed = nextLabel name breed --price = nextLabel breed price do not compile with errors --Main.hs:15:8-17: Not in scope: `firstLabel' --Main.hs:16:8-16: Not in scope: `nextLabel' A quick show ghc-pkg describe HList shows that --exposed-modules: HList --hidden-modules: Label4 CommonMain Variant GhcSyntax GhcRecord --Record HZip TIC TIP HTypeIndexed HOccurs HArray GhcExperiments --HListPrelude TypeEqBoolGeneric TypeEqGeneric1 TypeCastGeneric1 --FakePrelude So the question is do I need to play around with the cabal file to expose the right stuff? Or has the syntax changed? I get errors running ./setup haddock (configure, build, install, are fine). Are the HList api docs available anywhere online? Rahul ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Type without a data constructor?
Most examples for defining algebraic types include data constructors like so: data Tree a = Tip | Node a (Tree a) (Tree a) I by mistake defined a type which did not specify a data constructor : data SearchCondition = Term Bool | SearchCondition :||: (Term Bool) data Term a = Constant a sc :: SearchCondition sc = Term True is ok, but sc :: SearchCondition sc = Constant True is not (though this is what I intended to capture!). So the question is what are types with no constructors good for? A simple example would be appreciated. Rahul ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Type without a data constructor?
Constructors and names of data types live in separate namespaces. The above fact was the cause of all my confusion. It just slipped out of my mind. Cheers, Rahul ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] combinators for a simple grammar
I am having problems coming up with nice combinators for a simple DSEL. The abstract syntax is simply given by the types: data SearchCondition = SearchCondition BoolTerm | OpOr SearchCondition BoolTerm data BoolTerm = BoolTerm BoolFactor | OpAnd BoolTerm BoolFactor data BoolFactor = Constant Bool My current combinators are (.||.) :: SearchCondition - BoolTerm - SearchCondition (.||.) sc term = OpOr sc term (..) :: BoolTerm - BoolFactor - BoolTerm (..) term fact = OpAnd term fact which allow you to write expression of the form factTrue = Constant True termTrue = BoolTerm factTrue scTrue = SearchCondition termTrue sc = scTrue .||. termTrue .||. termTrue .. factTrue I am wondering it it is possible to define combinators to hide the structure of the grammar from the user to some extent, so that the user can simply write things like sc = True .||.True .||. True .. False or sc = const True .||. const True .||. const True .. const False That is the user does not have to worry about the distinction between terms and factors (which exists solely for precedence in this case). Or is it a better idea to just remove the precedence rules from the types and move it the part of the code that evaluates the expressions? Rahul ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] problems installing Takusen-0.6
I am having problems installing Takusen-0.6 (ghc 6.6.1 on FreeBSD) The configure and build works fine. running ./setup install fails with: Installing: /usr/local/lib/Takusen-0.6/ghc-6.6.1 /usr/local/bin Takusen-0.6... setup: Error: Could not find module: Database.Oracle.Enumerator with any suffix: [hi] I only have sqlite3 installed (no Oracle or Postgres). I followed the usual steps for the install ghc --make -o setup Setup.hs ./setup configure ./setup build ./setup install Any Ideas? Rahul ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe