Re: [Haskell-cafe] Employment
On Mon, Jan 19, 2009 at 3:04 PM, Andrew Coppin andrewcop...@btinternet.com wrote: Like many people I'm sure, I'd like to get paid to code stuff in Haskell. But I can't begin to imagine how you go about doing that... At Eaton, we're using Haskell to design automotive control systems (see http://cufp.galois.com/). In a 3 month span we went from 98K lines of Simulink, Matlab, and VisualBasic to 4K lines of Haskell. The system is now in vehicle testing and is going to production mid this year. In addition to tuning control laws and fault monitors, other fun things we are using Haskell for is to integrate our environment with an SMT solver for infinite state, bounded model checking. Unfortunately, due to economic conditions, all new openings have been temporarily put on hold. However, we expect new reqs to open as soon as conditions improve. When this happens, it would be nice if we had a single source to find qualified people. Maybe the community should consider building a database to help people who want to write Haskell for a living get in touch with employers who want to hire them. Such a database would help me counter by boss's argument that it's impossible to find and hire Haskell programmers. -Tom ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Type Family Relations
Hi, I like collecting examples of different type system related issues, and I am curious in what way is the solution that I posted limited. Do you happen to have an example? Hi Iavor, I think that class HeaderOf addr hdr | addr - hdr does not enforce that there must be a corresponding instance AddressOf hdr addr. Hence, the type checker cannot use that information either. Do you have a way to remedy that? Cheers, Tom On Sat, Jan 3, 2009 at 8:35 PM, Thomas DuBuisson thomas.dubuis...@gmail.com wrote: Thank you all for the responses. I find the solution that omits type families [Diatchki] to be too limiting while the solution 'class (Dual (Dual s) ~ s) =' [Ingram] isn't globally enforced. I've yet to closely study your first solution, Ryan, but it appears to be what I was looking for - I'll give it a try in the coming week. Tom On Sat, Jan 3, 2009 at 8:18 PM, Iavor Diatchki iavor.diatc...@gmail.com wrote: Hello, Usually, you can program such things by using super-classes. Here is how you could encode your example: {-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies, FlexibleInstances #-} class HeaderOf addr hdr | addr - hdr class HeaderOf addr hdr = AddressOf hdr addr | addr - hdr data IPv4Header = C1 data IPv4 = C2 data AppAddress = C3 data AppHeader = C4 instance AddressOf IPv4Header IPv4 instance HeaderOf IPv4 IPv4Header {- results in error: instance AddressOf AppHeader AppAddress instance HeaderOf AppAddress [AppHeader] -} Hope that this helps, Iavor On Sat, Jan 3, 2009 at 7:22 AM, Thomas DuBuisson thomas.dubuis...@gmail.com wrote: Cafe, I am wondering if there is a way to enforce compile time checking of an axiom relating two separate type families. Mandatory contrived example: type family AddressOf h type family HeaderOf a -- I'm looking for something to the effect of: type axiom HeaderOf (AddressOf x) ~ x -- Valid: type instance AddressOf IPv4Header = IPv4 type instance HeaderOf IPv4 = IPv4Header -- Invalid type instance AddressOf AppHeader = AppAddress type instance HeaderOf AppAddress = [AppHeader] So this is a universally enforced type equivalence. The stipulation could be arbitrarily complex, checked at compile time, and must hold for all instances of either type family. Am I making this too hard? Is there already a solution I'm missing? Cheers, Tom ___ 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 -- Tom Schrijvers Department of Computer Science K.U. Leuven Celestijnenlaan 200A B-3001 Heverlee Belgium tel: +32 16 327544 e-mail: tom.schrijv...@cs.kuleuven.be url: http://www.cs.kuleuven.be/~toms/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Typeclass question
Andrew Wagner wagner.andrew at gmail.com writes: I'm sure there's a way to do this, but it's escaping me at present. I want to do something like this: data Foo = Bar a = Foo a Bool ... That is, I want to create a new type, Foo, whose constructor takes both a Boolean and a value of a type of class Bar. Sometimes it's enough to declare data Foo a = Foo a Bool and to put the 'Bar a =' context onto the functions and instances that involve Foo. For example, in Chris Okasaki's book Purely Functional Data Structures, the h in data BootstrapHeap h a = ... is always meant to satisfy 'Heap h =', but this is ensured by putting the context at all the points where a BootstrapHeap is created, and not exporting BootstrapHeap's data constructors. Regards, Tom ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] FunDeps vs. Associated Types
On Fri, 5 Dec 2008, Sebastian Fischer wrote: Dear Haskellers, I have a question regarding the correspondence between functional dependencies and associated types. {-# LANGUAGE TypeFamilies, FlexibleInstances, MultiParamTypeClasses, FunctionalDependencies #-} With associated types, we can define a (useless[^1]) type class class Useless a where type T a useless :: a - T a and instances instance Useless () where type T () = () useless = id instance Useless a = Useless (() - a) where type T (() - a) = T a useless f = useless (f ()) Now we can compute `()` in many different ways: useless () useless (\()-()) ... I thought I could express the same with a multi-parameter type class and a functional dependency: class UselessFD a b | a - b where uselessFD :: a - b But the corresponding instances instance UselessFD () () where uselessFD = id instance UselessFD a b = UselessFD (() - a) b where uselessFD f = uselessFD (f ()) are not accepted (at least by ghc-6.10.1) without allowing undecidable instances: useless.lhs:50:2: Illegal instance declaration for `UselessFD (() - a) b' (the Coverage Condition fails for one of the functional dependencies; Use -XUndecidableInstances to permit this) In the instance declaration for `UselessFD (() - a) b' Is there a simple explanation for this? GHC does not implement the same conditions for type families and functional dependencies. Theoretically the same conditions may be used for both. The Coverage Condition is unnecessarily restrictive. A more relaxed condition has been proposed in the literature (JFP paper on using CHRs for FDs; our ICFP'08 paper), which GHC implements for type families but not functional dependencies. -- Tom Schrijvers Department of Computer Science K.U. Leuven Celestijnenlaan 200A B-3001 Heverlee Belgium tel: +32 16 327544 e-mail: [EMAIL PROTECTED] url: http://www.cs.kuleuven.be/~toms/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Searching for ADT patterns with elem and find
somebody pointed out a few months back that list comprehensions do this nicely: containsTypeB ts = not $ null [x | (B x) - ts] no need for defining isTypeB. not quite sure how you would write findBs :: [T]-[T] succinctly; maybe findBs ts = [b | b@(B _) - ts] or findBs ts = [B x | (B x) - ts] both of them compile but the first is ugly and the second is inefficient (Tags a new T for every hit). Tom 2008/11/12 Paul Keir [EMAIL PROTECTED]: Hi All, If I have an ADT, say data T = A String Integer | B Double | C deriving(Eq) and I want to find if a list (ts) of type T contains an element of subtype B Double, must my containsTypeX function use a second isTypeX function as follows: isTypeB :: T - Bool isTypeB (B _) = True isTypeB _ = False containsTypeB :: [T] - Bool containsTypeB ts = maybe False (\x - True) (find isTypeB ts) I understand that while something like find C ts will work, find (isTypeB _) ts will not, but is there no such thing as a pattern combinator(?), or lambda that could help with this situation. I find I have many individual isTypeB functions now. Regards, Paul ___ 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] What *not* to use Haskell for
On Tue, Nov 11, 2008 at 5:18 AM, Jules Bean [EMAIL PROTECTED] wrote: Dave Tapley wrote: Hi everyone So I should clarify I'm not a troll and do see the Haskell light. But one thing I can never answer when preaching to others is what does Haskell not do well? GHC's scheduler lacks any hard timeliness guarantees. Thus it's quite hard to use haskell in realtime or even soft-realtime environments. Actually, Haskell is an excellent language for hard real-time applications. At Eaton we're using it for automotive powertrain control. Of course, the RTS is not running in the loop. Instead, we write in a DSL, which generates C code for our vehicle ECU. Thanks to this great language, we traded 100K lines of Simulink for 3K lines of Haskell. Our current program is planned to hit the production lines in a few months. With similar methods, Haskell is also a great language for ASIC and FPGA design. -Tom ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Haddock on cygwin
I'm having the following issue with Haddock 2.0 and GHC 6.8.3 on cygwin: $ haddock -o doc --html -B /cygdrive/c/Program\ Files/Haskell/ghc-6.8.3/lib Test.hs $ haddock.exe: Can't find package.conf as \cygdrive\c\Program Files\Haskell\ghc-6.8.3\lib\driver\package.conf.inplace The windows install of GHC 6.8.3 does not have a driver/package.conf.inplace in ghc-6.8.3/lib. Any ideas? -Tom ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Hmm, what license to use?
Don thinking that compiler developer fragmentation doesn't help now the language research is 'done' Language researchers should move to a new language? Tom -- Tom Schrijvers Department of Computer Science K.U. Leuven Celestijnenlaan 200A B-3001 Heverlee Belgium tel: +32 16 327544 e-mail: [EMAIL PROTECTED] url: http://www.cs.kuleuven.be/~toms/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Comparing GADTs for Eq and Ord
Thanks for all the input. It helped me arrive at the following solution. I took the strategy of converting the parameterized type into an unparameterized type which can be easily compared for Eq and Ord. The unparameterized type enumerates the possible Const types with help from an auxiliary type class. -- The primary Expr type. data Expr a where Const :: ExprConst a = a - Expr a Equal :: Expr a - Expr a - Expr Bool -- An untyped Expr used to compute Eq and Ord of the former. -- Note each type of constant is enumerated. data UExpr = UConstBool Bool | UConstIntInt | UConstFloat Float | UEqual UExpr UExpr deriving (Eq, Ord) -- A type class to assist in converting Expr to UExpr. classExprConst a where uexprConst :: a - UExpr instance ExprConst Bool where uexprConst = UConstBool instance ExprConst Int where uexprConst = UConstInt instance ExprConst Float where uexprConst = UConstFloat -- The conversion function. uexpr :: Expr a - UExpr uexpr (Const a) = uexprConst a uexpr (Equal a b) = UEqual (uexpr a) (uexpr b) -- Finally the implementation of Eq and Ord for Expr. instance Eq (Expr a) where a == b = uexpr a == uexpr b instance Ord (Expr a) where compare a b = compare (uexpr a) (uexpr b) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Comparing GADTs for Eq and Ord
On Mon, Sep 15, 2008 at 3:11 PM, apfelmus [EMAIL PROTECTED] wrote: So, in other words, in order to test whether terms constructed with Equal are equal, you have to compare two terms of different type for equality. Well, nothing easier than that: (===) :: Expr a - Expr b - Bool Const === Const = True (Equal a b) === (Equal a' b') = a === a' b === b' _ === _ = False instance Eq (Expr a) where (==) = (===) OK. But let's modify Expr so that Const carries values of different types: data Expr :: * - * where Const :: a - Term a Equal :: Term a - Term a - Term Bool How would you then define: Const a === Const b = ... -Tom ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Currying function using values from array
Maybe you want something like curryWithList :: ([a]-b)-[a]-([a]-b) curryWithList f lst1= \lst2 -f (lst1++lst2) addThemUp = sum curried = curryWithList addThemUp [1,2,3,4] curried [5] =15 On Thu, Aug 7, 2008 at 8:35 PM, Henning Thielemann [EMAIL PROTECTED] wrote: On Thu, 7 Aug 2008, Sukit Tretriluxana wrote: Dear Haskell experts, I am currently studying Groovy language. An experiment I did with its closure is to perform closure/function curry using an array containing the values for the parameter binding. See the sample below. int addThemUp(a,b,c,d,e) { a+b+c+d+e } def arrayCurry(arr, cls) { arr.inject(cls) { c, v - c.curry(v) } } println addThemUp(1,2,3,4,5) println arrayCurry([1,2,3,4,5], this.addThemUp)() println arrayCurry([1,2,3,4], this.addThemUp)(5) The printouts from the above code are the same, verifying that the code works fine. Then I come to ask myself how I can do the same in Haskell. I'm not a Haskell expert so I couldn't figure it. I wonder if you guys could shed some light on this. I do not know Groovy, but maybe you want something like addThemUp :: Num a = (a,a,a,a,a) - a addThemUp (a,b,c,d,e) = a+b+c+d+e -- should be better named list5Curry or so arrayCurry :: ((a,a,a,a,a) - a) - [a] - a arrayCurry cls [a,b,c,d,e] = cls (a,b,c,d,e) print (addThemUp(1,2,3,4,5::Int)) print (arrayCurry addThemUp [1,2,3,4,5::Int]) However, it's hardly of any use, since you won't use a list if the number of elements is fixed (and small) or if the elements even must have distinct types. ___ 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] Copying Arrays
I'm trying to implement some file I/O where I can read in a file to an array, but do so without having to know how much space I will need. (Before you suggest it, lists are too slow/space consuming.) I was thinking that one possible solution is to use a strategy used in dynamic arrays, where everytime you run out of space you double the capacity of the array. Trouble is, most arrays in Haskell would require you to traverse the entire array and copy each individual cell, which would make it worthless. Are there any low-level array types (MutableByteArray#, for example) that support a memcpy-like function where I could copy the entire array into the new one instead of copying it one value at a time? Is there another solution that I'm missing? -- Tom Harper MSc Computer Science '08 University of Oxford Mobile: +44 (0)7533 998 591 Skype: +1 949 273 4627 (harpertom) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Copying Arrays
Why not just read it into a lazy ByteString? Are you looking to use an array with elements of a different type? You could then convert it to a strict ByteString. b Because I'm writing the Unicode-friendly ByteString =p -- Tom Harper MSc Computer Science '08 University of Oxford Mobile: +44 (0)7533 998 591 Skype: +1 949 273 4627 (harpertom) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Benchmarking Framework
I am in the process of writing a library for my MSc dissertation and would like to do some benchmarking. In doing so I need to compare the time and space of my library with some other code. Is there a framework for doing so in Haskell, aside from the Profiling tools in GHC? Basically I'm looking for something like QuickCheck, but that helps with generating repeatable tests to measure performance. Is there anything out there that anyone would recommend? -- Tom Harper MSc Computer Science '08 University of Oxford Mobile: +44 (0)7533 998 591 Skype: +1 949 273 4627 (harpertom) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Analog data acquisition
Hello, I would like to use a lazy, purely functional language to create an experiement description (and execution!) language for cellular neuroscience, i.e. electrical recordings and stimulation. Unfortunately, this means I have to talk to a Analog-to-Digital/Digital-to-Analog converter board, with a precision of about 16 bit at a rate of 50 kHz. I currently have a National Instruments M-series board, but would be happy to try another board. I'm not looking for real-time control right now, but that might be of interest in the future. Has anyone looked at creating bindings to the NI-DAQmx drivers or the open-source COMEDI project, or similar hardware? Would anyone be interested in helping out with this driver binding? Regards Tom ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Analog data acquisition
Yes. I guess I have to wait for chapter 19, then? Tom On Tue, May 13, 2008 at 7:35 PM, Don Stewart [EMAIL PROTECTED] wrote: tanielsen: Hello, I would like to use a lazy, purely functional language to create an experiement description (and execution!) language for cellular neuroscience, i.e. electrical recordings and stimulation. Unfortunately, this means I have to talk to a Analog-to-Digital/Digital-to-Analog converter board, with a precision of about 16 bit at a rate of 50 kHz. I currently have a National Instruments M-series board, but would be happy to try another board. I'm not looking for real-time control right now, but that might be of interest in the future. Has anyone looked at creating bindings to the NI-DAQmx drivers or the open-source COMEDI project, or similar hardware? Would anyone be interested in helping out with this driver binding? I'm assuming there are existing C libraries for this? So a Haskell binding would just talk to these? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] looking for examples of non-full Functional Dependencies
On Fri, 25 Apr 2008, Hans Aberg wrote: On 18 Apr 2008, at 20:04, Martin Sulzmann wrote: Let's consider our running example class D a b | a - b instance D a b = D [a] [b] which we can write in CHR notation D a b, D a c == b=c(FD) D [a] [b] = D a b (Inst) These rules overlap. I experimented with translations into GNU Prolog (gprolog). Since = is hard to get working in Prolog unless integrated into unification, I tried (using the idea of rewriting unique existence as functions, possible if one assumes the axiom of choice): class(d, A, b(A)). instance(d, l(A), l(B)) :- class(d, A, B). Then: ?- instance(d, l(A), l(B)). B = b(A) ?- instance(d, l(A), C). C = l(b(A)) ?- instance(d, l(A), l(B)), instance(d, l(A), C). B = b(A) C = l(b(A)) Though I am not sure about the intended semantics, it does produce unique solutions. Prolog works under the assumption of a closed world. That's contrary to the open world view of regular type classes. So these aren't the intended semantics. Tom -- Tom Schrijvers Department of Computer Science K.U. Leuven Celestijnenlaan 200A B-3001 Heverlee Belgium tel: +32 16 327544 e-mail: [EMAIL PROTECTED] url: http://www.cs.kuleuven.be/~toms/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] looking for examples of non-full Functional Dependencies
On Fri, 25 Apr 2008, Hans Aberg wrote: On 25 Apr 2008, at 14:20, Tom Schrijvers wrote: Prolog works under the assumption of a closed world. That's contrary to the open world view of regular type classes. So these aren't the intended semantics. By which I gather you mean the interpretation of :- as logical connective = rather than provability |-? What I meant was that when Prolog says there are no more solutions, it doesn't know of any more. In realtiy it means there no more solutions under the closed world assumption. That means there could be more solutions if you haven't told Prolog everything. In this context, there may be more class instances (you simply haven't told the system yet). My point, though, was to interpret class a b | a - b as a functional dependency b = b(a) rather than as D a b, D a c == b=c Thus trying to eliminate the use of =. I don't follow you here. Tom -- Tom Schrijvers Department of Computer Science K.U. Leuven Celestijnenlaan 200A B-3001 Heverlee Belgium tel: +32 16 327544 e-mail: [EMAIL PROTECTED] url: http://www.cs.kuleuven.be/~toms/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] looking for examples of non-full Functional Dependencies
hackageDB has a substantial sample of code these days, which is handy for questions like this. Thanks, Ross. These examples are perfect! Cheers, Tom -- Tom Schrijvers Department of Computer Science K.U. Leuven Celestijnenlaan 200A B-3001 Heverlee Belgium tel: +32 16 327544 e-mail: [EMAIL PROTECTED] url: http://www.cs.kuleuven.be/~toms/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] looking for examples ofnon-fullFunctional Dependencies
a little more experimentation leaves me confused. consider [4] class C a b c | a - b -- , a - c instance C a b b = C [a] [b] [b] Hugs: :t undefined :: C [x] y z = (x,y,z) undefined :: C [a] [b] c = (a,[b],c) GHCi: :t undefined :: C [x] y z = (x,y,z) undefined :: C [x] y z = (x,y,z) :: (C [x] [b] z) = (x, [b], z) both systems improve 'y' to '[b]', but not to '[b] where z=[b]'. ok, the third parameter is not in range of an FD, so cannot be instantiated by improvement, and without that, 'y' cannot be instantiated as far as the FD would suggest. it is slightly surprising that 'y' get partially instantiated at this stage. My understanding of an FD a - b is to improve, or in other words instantiate, b as much as possible based on information from a. With C [x] y z we know for sure that y must be [b] for some b. Improvement adds (propagates) this information we know for sure. With our limited information, we may not know what b is, but just knowing the list type constructor [] may already be useful. For instance, if we had a second type class constraint D y for which there is an instance instance D [a] where ... Then inferring that y = [b] will allow us to figure out that we can use the above instance for it. however, if we try to help the process along by instantiating 'z' to '[b]' ourselves, we get: [5] Hugs: :t undefined :: C [x] y [b] = (x,y,[b]) undefined :: C [a] [b] [c] = (a,[b],[c]) GHCi: :t undefined :: C [x] y [b] = (x,y,[b]) undefined :: C [x] y [b] = (x,y,[b]) :: (C [x] [b1] [b]) = (x, [b1], [b]) i would have expected 'C a c c = (a,[c],[c])' here, as only instantiation of 'y' is required; so my intuition is still off, and neither [A] nor [B] seems to capture Hugs' interpretation. You did not provide the FD a - c (or even a - b c). That means that you did not allow the type checker to improve c based on a. Nor did you provide the FD a c - b. For that reason the type checker does not use any information from the third parameter to improve the second parameter. It does indeed feel somewhat strange, because there is no alternative for y (except if you allow overlapping instances and add e.g. an instance C [a] [b] [Int]). Cheers, Tom -- Tom Schrijvers Department of Computer Science K.U. Leuven Celestijnenlaan 200A B-3001 Heverlee Belgium tel: +32 16 327544 e-mail: [EMAIL PROTECTED] url: http://www.cs.kuleuven.be/~toms/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] looking for examples of non-full Functional Dependencies
Hello, I'm looking for practical examples of non-full functional dependencies and would be grateful if anyone could show me some or point to applications using them. A non-full functional dependency is one involves only part of the parameters of a type class. E.g. class C a b c | a - b has a non-full functional dependency a - b which does not involve c. Thanks, Tom -- Tom Schrijvers Department of Computer Science K.U. Leuven Celestijnenlaan 200A B-3001 Heverlee Belgium tel: +32 16 327544 e-mail: [EMAIL PROTECTED] url: http://www.cs.kuleuven.be/~toms/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: type families and type signatures
However, I have this feeling that bar :: forall a . Id a - String with a type family Id *is* parametric in the sense that no matter what a is, the result always has to be the same. Intuitively, that's because we may not pattern match on the branch of a definition like type instance Id String = .. type instance Id Int= .. .. But in a degenerate case there could be just this one instance: type instance Id x = GADT x which then reduces this example to the GADT case of which you said that is was clearly parametric. Tom -- Tom Schrijvers Department of Computer Science K.U. Leuven Celestijnenlaan 200A B-3001 Heverlee Belgium tel: +32 16 327544 e-mail: [EMAIL PROTECTED] url: http://www.cs.kuleuven.be/~toms/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: type families and type signatures
Hi Tom, It seems we are thinking of different things. I was referring to the characterization of a type of the form P = t as being ambiguous if there is a type variable in P that is not determined by the variables in t; this condition is used in Haskell to establish coherence (i.e., to show that a program has a well-defined semantics). [...] Technically, one could ignore the ambiguous type signature for bar, because the *principal* type of bar (as opposed to the *declared type*) is not ambiguous. However, in practice, there is little reason to allow the definition of a function with an ambiguous type because such functions cannot be used in practice: the ambiguity that is introduced in the type of bar will propagate to any other function that calls it, either directly or indirectly. For this reason, it makes sense to report the ambiguity at the point where bar is defined, instead of deferring that error to places where it is used, like the definition of bar'. (The latter is what I mean by delayed ambiguity checking.) Thanks for explaining the ambiguity issue, Mark. I wasn't thinking about that. We have thought about ambiguity. See Section 7.3 in our paper http://www.cs.kuleuven.be/~toms/Research/papers/draft_type_functions_2008.pdf Note that neither Definition 3 nor Definition 4 demands that all unification variables are substituted with ground types during type checking. So we do allow for a form of ambiguity: when any type is valid (this has no impact on the semantics). Consider the initial program type family F a foo :: F a - F a foo = id You propose to reject function Foo because it cannot be used unambiguously. We propose to accept foo, because the program could be extended with type instance F x = Int and, for instance, this would be valid: foo2 :: F Char - F Bool foo2 = foo If you look at the level of the equality constraints: (F Char - F Bool) ~ (F alpha - F alpha) we normalise first wrt the instance F x = Int, and get (Int - Int) ~ (Int - Int) which is trivially true. In this process we do not substitute alpha. So alpha is ambiguous, but any solution will do and not have an impact on program execution. GHC already did this before type functions, for this kind of ambiguity, it substitutes alpha for an arbitrary type. That's not unreasonable, is it? Cheers, Tom -- Tom Schrijvers Department of Computer Science K.U. Leuven Celestijnenlaan 200A B-3001 Heverlee Belgium tel: +32 16 327544 e-mail: [EMAIL PROTECTED] url: http://www.cs.kuleuven.be/~toms/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: type families and type signatures
type instance Id Int = Int foo :: Id a - Id a foo = id foo' :: Id a - Id a foo' = foo Is this expected? Yes, unfortunately, this is expected, although it is very unintuitive. This is for the following reason. Huh? This sounds very wrong to me, simply because foo and foo' have the very same type. Type systems reject programs that don't go wrong. It's hard to understand on the basis of such a single program why it should be rejected. The problem is decidability. There is no algorithm that accepts all well-behaved programs and rejects all ill-behaved programs. There probably is an algorithm that accepts a particular program. So far we haven't found an algorithm that accepts this example, that is decidable and sufficiently general to cover many other useful cases. This is our motivation for rejecting this program. Consider it a challenge to find a better algorithm in the design space. Cheers, Tom -- Tom Schrijvers Department of Computer Science K.U. Leuven Celestijnenlaan 200A B-3001 Heverlee Belgium tel: +32 16 327544 e-mail: [EMAIL PROTECTED] url: http://www.cs.kuleuven.be/~toms/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: type families and type signatures
On Mon, 7 Apr 2008, Mark P Jones wrote: The surprising thing about this example is the fact that the definition of foo is accepted, and not the fact that the definition of foo' is rejected. At least in Manuel's equivalent program using functional dependencies, both functions have ambiguous types, and hence both would be rejected. It sounds like your implementation may be using a relaxed approach to ambiguity checking that delays ambiguity checking from the point of definition to the point of use. Although this is probably still sound, it can lead to puzzling error diagnostics ... On the algorithmic level I don't see a relaxed approach to ambiguity checking. If alpha is a unifiction variable, you get for the first body (Id a - Id a) ~ (alpha ~ alpha) where there is no ambiguity: the unique solution (modulo equality theory) is alpha := Id a. For the second body you get (Id a - Id a) ~ (Id alpha - Id alhpa) This equation reduces to Id a ~ Id alpha. Our algorithm stops here. There is in general no single solution for alpha (*) in such an equation, as opposed to the above case. I hope this clarifies our algorithm. Cheers, Tom All the best, Mark Tom Schrijvers wrote: type instance Id Int = Int foo :: Id a - Id a foo = id foo' :: Id a - Id a foo' = foo Is this expected? Yes, unfortunately, this is expected, although it is very unintuitive. This is for the following reason. Huh? This sounds very wrong to me, simply because foo and foo' have the very same type. Type systems reject programs that don't go wrong. It's hard to understand on the basis of such a single program why it should be rejected. The problem is decidability. There is no algorithm that accepts all well-behaved programs and rejects all ill-behaved programs. There probably is an algorithm that accepts a particular program. So far we haven't found an algorithm that accepts this example, that is decidable and sufficiently general to cover many other useful cases. This is our motivation for rejecting this program. Consider it a challenge to find a better algorithm in the design space. Cheers, Tom -- Tom Schrijvers Department of Computer Science K.U. Leuven Celestijnenlaan 200A B-3001 Heverlee Belgium tel: +32 16 327544 e-mail: [EMAIL PROTECTED] url: http://www.cs.kuleuven.be/~toms/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Tom Schrijvers Department of Computer Science K.U. Leuven Celestijnenlaan 200A B-3001 Heverlee Belgium tel: +32 16 327544 e-mail: [EMAIL PROTECTED] url: http://www.cs.kuleuven.be/~toms/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Wumpus World
Not all students and researchers can afford a Personal License. Can you recommend an alternative, fast Prolog development system under a free licensing agreement, such as GPL/GLPL? SWI-Prolog is about the best and most popular open Prolog system: http://www.swi-prolog.org It's not the fastest, just like GCC doesn't generates the fastest code. Who cares? If you want speed, then Yap is the best open Prolog system. http://www.ncc.up.pt/~vsc/Yap/ Cheers, Tom -- Tom Schrijvers Department of Computer Science K.U. Leuven Celestijnenlaan 200A B-3001 Heverlee Belgium tel: +32 16 327544 e-mail: [EMAIL PROTECTED] url: http://www.cs.kuleuven.be/~toms/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Equality constraints in type families
could you please help me to clear up this confusion?-) Let me summarize :-) The current design for type functions with result kinds other than * (e.g. * - *) has not gotten very far yet. We are currently stabilizing the ordinary * type functions, and writing the story up. When that's done we can properly focus on this issue and consider different design choices. Cheers, Tom -- Tom Schrijvers Department of Computer Science K.U. Leuven Celestijnenlaan 200A B-3001 Heverlee Belgium tel: +32 16 327544 e-mail: [EMAIL PROTECTED] url: http://www.cs.kuleuven.be/~toms/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Equality constraints in type families
On Tue, 11 Mar 2008, Hugo Pacheco wrote: Yes, I have tried both implementations at the start and solved it by choosing for the following: type family F a :: * - * type FList a x = Either () (a,x) type instance F [a] = FList a instance (Functor (F [a])) where fmap _ (Left _) = Left () fmap f (Right (a,x)) = Right (a,f x) For this implementation we do have that F [a] b ~ F [c] d = F [a] ~ F [c] /\ b ~ d Right? So for this instance, your para via hylo wouldn't work anyway. I'd like to see some type instances and types such that the equation F d a ~ F a (a,a) holds. With your example above, it's not possible to make the equation hold, .e.g. F [t] [s] ~ F [s] ([s],[s]) = Either () (t,[s]) ~ Either ()(s,([s],[s])) is not true for any (finite) types t and s. Do you have such an example? You should have one, if you want to be able to call para. Tom I have my suspicions about your mentioning of both Functor (F d) and Functor (F a) in the signature. Which implementation of fmap do you want? Or should they be both the same (i.e. F d ~ F a)? This is an hard question to which the answer is both. In the definition of an hylomorphism I want the fmap from (F d): hylo :: (Functor (F d)) = d - (F d c - c) - (a - F d a) - a - c hylo d g h = g . fmap (hylo d g h) . h However, those constraints I have asked about would allow me to encode a paramorphism as an hylomorphism: class Mu a where inn :: F a a - a out :: a - F a a para :: (Mu a, Functor (F a),Mu d, Functor (F d),F d a ~ F a (a,a), F d c ~ F a (c,a)) = d - (F a (c,a) - c) - a - c para d f = hylo d f (fmap (id /\ id) . out) In para, I would want the fmap from (F a) but that would be implicitly forced by the usage of out :: a - F a a Sorry for all the details, ignore them if they are too confusing. Do you think there might be a definition that would satisfy me both Functor instances and equality? Thanks for your pacience, hugo -- Tom Schrijvers Department of Computer Science K.U. Leuven Celestijnenlaan 200A B-3001 Heverlee Belgium tel: +32 16 327544 e-mail: [EMAIL PROTECTED] url: http://www.cs.kuleuven.be/~toms/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Equality constraints in type families
Hi Hugo, I have encoded a type family such that: type family F a :: * - * and a function (I know it is complicated, but I think the problem is self explanatory): hyloPara :: (Functor (F a), Functor (F d), F d a ~ F a (a,a), F d c ~ F a (c,a)) = d - (F d c - c) - (a - F d a) - a - c hyloPara d g h = g . fmap (hyloPara d g h) . h it all works fine. However, if I change the declaration to (changed F d c for the supposedly equivalent F a (c,a)): hyloPara :: (Functor (F a), Functor (F d), F d a ~ F a (a,a), F d c ~ F a (c,a)) = d - (F a (c,a) - c) - (a - F d a) - a - c and I get Occurs check: cannot construct the infinite type: c = (c, a) When generalising the type(s) for `hyloPara' This really messes up my notions on equality constraints, is it the expected behavior? It would be essential for me to provide this definition. I think you've uncovered a bug in the type checker. We made the design choice that type functions with a higher-kinded result type must be injective with respect to the additional paramters. I.e. in your case: F x y ~ F u v = F x ~ F u /\ y ~ v So if we apply that to F d c ~ F a (c,a) we get: F d ~ F a /\ c ~ (c,a) where the latter clearly is an occurs-check error, i.e. there's no finite type c such that c = (c,a). So the error in the second version is justified. There should have been one in the latter, but the type checker failed to do the decomposition: a bug. What instances do you have for F? Are they such that F d c ~ F a (c,a) can hold? By the way, for your function, you don't need equations in your type signature. This will do: hyloPara :: Functor (F d) = d - (F d c - c) - (a - F d a) - a - c Cheers, Tom -- Tom Schrijvers Department of Computer Science K.U. Leuven Celestijnenlaan 200A B-3001 Heverlee Belgium tel: +32 16 327544 e-mail: [EMAIL PROTECTED] url: http://www.cs.kuleuven.be/~toms/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Equality constraints in type families
On Tue, 11 Mar 2008, Hugo Pacheco wrote: I know I do not need these constraints, it was just the simplest way I found to explain the problem. I have fought about that: I was not expecting F d c ~ F a (c,a) not mean that F d ~F a /\ c ~(c,a), I thought the whole family was parameterized. If I encoded the family type family F a x :: * F d c ~ F a (c,a) would be semantically different, meaning that this decomposition rule does not apply? Correct. However, then you cannot write Functor (F a) because type functions must be fully applied. So either way you have a problem. Could you show the type instances for F you have (in mind)? This way we can maybe see whether what you want to is valid and the type checker could be adjusted to cope with it, or whether what you're trying to do would not be valid (in general). I have my suspicions about your mentioning of both Functor (F d) and Functor (F a) in the signature. Which implementation of fmap do you want? Or should they be both the same (i.e. F d ~ F a)? Cheers, Tom -- Tom Schrijvers Department of Computer Science K.U. Leuven Celestijnenlaan 200A B-3001 Heverlee Belgium tel: +32 16 327544 e-mail: [EMAIL PROTECTED] url: http://www.cs.kuleuven.be/~toms/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Small displeasure with associated type synonyms
Stefan, I tried lexically scoped type variables, but to no avail: instance forall a b. (C a, C b) = C (a, b) where type T (a, b) = (T a, T b) val = (val :: T a, val :: T b) The problem is ambiguity. The type checker can't determine which val function to use, i.e. which dictionary to pass to val. Assume: instance C Int where type T Int = Int val= 0 instance C Bool where type T Bool = Int val = 1 Now, if you want some val :: Int, which one do you get? The one of C Int of C Bool? Depending on the choice you may get a different result. We can't have that in a deterministic functional language. Hence the error. Adding a type signature doesn't change the matter. Providing an additional argument, as you propose, resolves the ambiguity. I hope this helps. Cheers, Tom -- Tom Schrijvers Department of Computer Science K.U. Leuven Celestijnenlaan 200A B-3001 Heverlee Belgium tel: +32 16 327544 e-mail: [EMAIL PROTECTED] url: http://www.cs.kuleuven.be/~toms/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Small displeasure with associated type synonyms
I don't see how your example explains this particular error. I agree Int cannot be generalized to (T Int) or (T Bool). Generalized is not the right word here. In my example T Int, T Bool and Int are all equivalent. I see Stefan's local type signature is not (val :: a) like your (val ::Int) but (val :: T a) which is a whole different beast. Not all that different. As in my example the types T Int, T Bool and Int are equivalent, whether one writes val :: Int, val :: T Int or val :: T Bool. My point is that writing val :: T Int or val :: T Bool does not help determining whether one should pick the val implementation of instance C Int or C Bool. And (T a) is the type that ghc should assign here. As my example tries to point out, there is not one single syntactic form to denote a type. Consider the val of in the first component. Because of val's signature in the type class the type checker infers that the val expression has a type equivalent to T a2 for some a2. The type checker also expects a type equivalent to T a, either because of the type annotation or because of the left hand side. So the type checker must solve the equation T a ~ T a2 for some as yet to determine type a2 (a unification variable). This is precisely where the ambiguity comes in. The type constructor T is not injective. That means that the equation may hold for more than one value of a2 (e.g. for T Int ~ T a2, a2 could be Int or Bool). Hence, the type checker complains: Couldn't match expected type `T a2' against inferred type `T a'. Maybe you don't care what type is chosen, if multiple ones are possible. My example tried to show that this can effect the values computed by your program. So it does matter. For this particular example, it seems that the type checker does not have have more than alternative for a2 in scope. However, it is not aware of that fact. It uniformly applies the same general strategy for solving equations in all contexts. This is a trade-off in type system complexity vs. expressivity. There is an opportunity for exploring another point in the design space here. Tom -- Tom Schrijvers Department of Computer Science K.U. Leuven Celestijnenlaan 200A B-3001 Heverlee Belgium tel: +32 16 327544 e-mail: [EMAIL PROTECTED] url: http://www.cs.kuleuven.be/~toms/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Small displeasure with associated type synonyms
Am I correct in thinking this would have worked if it were an associated type instead of an associated type synonym? ie, class C a where data T a val :: T a Yes, you are. Associate data type constructors (as well as ordinary algebraic data constructors) are injective. So we have: forall a b . T a = T b = a = b Cheers, Tom -- Tom Schrijvers Department of Computer Science K.U. Leuven Celestijnenlaan 200A B-3001 Heverlee Belgium tel: +32 16 327544 e-mail: [EMAIL PROTECTED] url: http://www.cs.kuleuven.be/~toms/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Haskell Jobs
Hi, We have an opening for a software engineer, with the potential for a lot of Haskell development. Our group at Eaton (http://www.eaton.com/) develops real-time control software for vehicle and machinery applications. This position is specifically for the design and verification of hydraulic hybrid vehicle systems. Think Toyota Prius, but with a accumulator and hydraulic pump instead of a battery and an electric motor. That, and these vehicles can weight over 30,000 pounds. The primary tasks would include vehicle software design, system verification with simulation and possibly formal analysis, telemetry development for remote diagnostics, and tool development to further automate our design flows. Currently we use Haskell for our in-house data analysis tools, and some vehicles run code partially generated by a Haskell DSL. We hope to expand our use of Haskell, especially for simulation regression suites -- maybe QuickCheck in combination with a system modeling and verification DSL. If interested, send a resume. Thanks! -Tom ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Arrow combinator names
Are there generally accepted English language names for the arrow combinators? compose? pair? etc... ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] I love purity, but it's killing me.
Hi Matt, On Feb 9, 2008 1:07 PM, Matthew Naylor [EMAIL PROTECTED] wrote: If you go the real compiler route, would it not make sense to take the DSL as the source language rather than Haskell? Or are the DSL and Haskell quite similar? The two are nearly identical. In fact the only significant difference between the languages is the semantics of top level monad; it wouldn't be IO, but something else. With the syntax the same, it could leverage much of Haskell's standard library. Or perhaps you are thinking of a two language system, where some code is evaluated at compile time by Haskell, and some is compiled to the target language? Not necessarily in the same compilation flow, but I can think of several scenarios where it would be advantageous for code written in this other language to be pulled into a conventional Haskell program. Taking options 2 or 5 just to solve the sharing problem sounds to me like a lot of hard work for little reward. But don't worry, I won't repeat my observable sharing speech. :-) So is the general strategy with observable sharing to use unsafePerformIO with Data.Unique to label expressions at construction? Ahh...clever! I did not think of this. Of course, now that you have me reading up on Yhc.Core, option #5 is looking considerably more fun. -Tom ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] I love purity, but it's killing me.
On 2/8/08, Emil Axelsson [EMAIL PROTECTED] wrote: I know of a few of ways to express sharing in a pure language: 1) Observable sharing, which, in general, is unsafe. 2) Using Template Haskell 3) Matthew Naylor has done some work on expressible sharing, which has 4) Use a monad (but I'm sure this is what you're trying to avoid). Or... 5) Forget embedding the DSL, and write a direct compiler. In addition to the sharing problem, another shortcoming of Haskell DSLs is they can not fully exploit the benefits of algebraic datatypes. Specifically, pattern matching ADTs can only be used to control the compile-time configuration of the target, it can't be used to describe the target's behavior -- at least for DSLs that generate code that executes outside of Haskell's runtime. Writing a real compiler would solve both of these problems. Is there any Haskell implementation that has a clean cut-point, from which I can start from a fully type-checked, type-annotated intermediate representation? And thanks for the link to John's paper describing Hydra's use of Template Haskell. I will definiately consider TH. -Tom ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] I love purity, but it's killing me.
I've been programming with Haskell for a few years and love it. One of my favorite applications of Haskell is using for domain specific languages. However, after designing a handful of DSLs, I continue to hit what appears to be a fundamental hurdle -- or at least I have yet to find an adequate solution. My DSLs invariably define a datatype to capture expressions; something like this: data Expression = Add Expression Expression | Sub Expression Expression | Variable String | Constant Int deriving Eq Using the datatype Expression, it is easy to mass a collections of functions to help assemble complex expressions, which leads to very concise programs in the DSL. The problem comes when I want to generate efficient code from an Expression (ie. to C or some other target language). The method I use invovles converting the tree of subexpressions into an acyclic graphic to eliminate common subexpressions. The nodes are then topologically ordered and assigned an instruction, or statement for each node. For example: let a = Add (Constant 10) (Variable i1) b = Sub (Variable i2) (Constant 2) c = Add a b would compile to a C program that may look like this: a = 10 + i1; b = i2 - 2; c = a + b; The process of converting an expression tree to a graph uses either Eq or Ord (either derived or a custom instance) to search and build a set of unique nodes to be ordered for execution. In this case a, then b, then c. The problem is expressions often have shared, equivalent subnodes, which dramatically grows the size of the tree. For example: let d = Add c c e = Add d d-- e now as 16 leaf nodes. As these trees grow in size, the equality comparison in graph construction quickly becomes the bottleneck for DSL compilation. What's worse, the phase transition from tractable to intractable is very sharp. In one of my DSL programs, I made a seemingly small change, and compilation time went from milliseconds to not-in-a-million-years. Prior to Haskell, I wrote a few DSLs in OCaml. I didn't have this problem in OCaml because each let expression was mutable, and I could use the physical equality operator to perform fast comparisons. Unfortunately, I have grown to love Haskell's type system and its lack of side effects, and could never go back. Is there anything that can be done to dramatically speed up comparisons, or is there a better approach I can take to extract common subexpressions? I should point out I have an opportunity to get Haskell on a real industrial application. But if I can't solve this problem, I may have to resort to far less eloquent languages. :-( Thanks for any and all help. -Tom ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Access to list
On Jan 13, 2008 7:55 AM, Fernando Rodriguez [EMAIL PROTECTED] wrote: If I define the follwoing functions: car (x:_) = x car [] = [] What's the type signature for that function? Cheers! --Tom Phoenix ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell-cafe reply-to etiquette
On Dec 27, 2007 3:36 PM, Justin Bailey [EMAIL PROTECTED] wrote: When I joined the haskell-cafe mailing list, I was surprised to see the reply-to header on each message was set to the sender of a given message to the list, rather than the list itself. That seemed counter to other mailing lists I had been subscribed to, but I didn't think too much about it. http://www.unicom.com/pw/reply-to-harmful.html Cheers! --Tom Phoenix ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] instance Monad Either?
On 12/20/07, Eric [EMAIL PROTECTED] wrote: According to this http://www.randomhacks.net/articles/2007/03/10/haskell-8-ways-to-report-errors Either is an instance of class Monad, but when I try to use the do notation I get a compiler error. What's going on? Near the bottom of that page is a comment by Luis Cabellos. Does that comment bring you any closer to enlightenment? Cheers! --Tom Phoenix ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Point and link
Andrew Coppin andrewcoppin at btinternet.com writes: [snip] You might like to look at OpenQuark: http://labs.businessobjects.com/cal/ -- its 'GemCutter' provides a visual environment for linking together functions written in a Haskell-like language. I'm not sure if it would be flexible enough for you out of the box, but it's open source so you might be able to adapt it. Tom ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] ANN: atom 2007.12
Hello, Atom is a language embedded in Haskell for describing reactive software, primarily for realtime control applications. Based on conditional term rewriting, an atom description is composed of a set of state transition rules. The name atom comes from the atomic behavior of rules: if a rule is selected to fire, all its transitions occur or none at all. A hallmark of the language, rule atomicity greatly simplifies design reasoning. This release of atom is a major redirection. Atom is no longer a hardware description language (I changed jobs. I'm now in software.). Much of the frontend language and backend generators have changed, though rule scheduling remains nearly the same. On the frontend, atom's Signal datatypes have been replaced with Terms and Vars, which leverage Haskell's GADTs. The 4 supported Term and Var types include Bool, Int, Float, and Double. At the backend, atom generates C and Simulink models. The Verilog and VHDL generators have been dropped, but they may reappear in the future. Enjoy! http://funhdl.org/ darcs get http://funhdl.org/darcs/atom -Tom ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] SingHaskell 2007, November 28 2007
We're pleased to invite you to SingHaskell: What is SingHaskell? Sing(apore)Haskell is a Haskell (and related languages) meeting in Singapore. The meeting is organized by Tom Schrijvers and Martin Sulzmann and will be hosted by the National University of Singapore. Date and location Sing(apore)Haskell takes place on Wed 28 Nov 2007 (right before APLAS'07 http://flint.cs.yale.edu/aplas2007/). The meeting will be held somewhere on the National University of Singapore campus (details will follow shortly). Let Tom or Martin know if you are interested in coming. Either to attend the meeting or even give a talk. For more information and tentaive talks: http://taichi.ddns.comp.nus.edu.sg/taichiwiki/SingHaskell2007 Best regards, Martin Sulzmann and Tom Schrijvers -- Tom Schrijvers Department of Computer Science K.U. Leuven Celestijnenlaan 200A B-3001 Heverlee Belgium tel: +32 16 327544 e-mail: [EMAIL PROTECTED] url: http://www.cs.kuleuven.be/~toms/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Stream fusion for Hackage
On Sat, 17 Nov 2007, Don Stewart wrote: Just a quick announce: the stream fusion library for lists, that Duncan Coutts, Roman Leshchinskiy and I worked on earlier this year is now available on Hackage as a standalone package: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/stream-fusion-0.1.1 As described in the recent paper: Stream Fusion: From Lists to Streams to Nothing at All Duncan Coutts, Roman Leshchinskiy and Don Stewart. ICFP 2007 This is a drop-in replacement for Data.List. Will it eventually replace Data.List in GHC? Tom -- Tom Schrijvers Department of Computer Science K.U. Leuven Celestijnenlaan 200A B-3001 Heverlee Belgium tel: +32 16 327544 e-mail: [EMAIL PROTECTED] url: http://www.cs.kuleuven.be/~toms/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Haskell Job Opportunity
Hello, Eaton (eaton.com, Eden Prairie, MN US) is seeking software engineers for design and verification of electro-hydraulic control systems for industrial, automotive, and aerospace applications. Though I am still trying to get Haskell on the official job description, here are a few of the potential Haskell applications: - Domain specific languages. - Compiler design and embedded code generation. - Model checking and equivalence checking. - SAT decision procedures. - Constrained random simulation. - Software timing analysis. General knowledge of the following would be helpful: - Control theory. - Real-time, embedded programming. - Automotive and industrial systems. - Hydraulics and fluid power. If interested, send me a resume. Thanks! -Tom Hawkins ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Type Synonyms
Newbie question: I was wondering the other day if type synonyms might be more useful if they were more restricted, that is, with the definitions: type Foo = String type Bar = String foo :: Foo foo = a foo bar :: Bar bar = a bar x :: Foo - ... x f b = ...only valid for Foo Strings... both 'x foo' and 'x bar' type check correctly. Wouldn't it be useful if Foo and Bar were both equivalent to String, but Foo and Bar were not equivalent themselves? For instance, if you are using Strings as properties of something and want to associate the type of the property with its value, without wrapping the String. Would this break a transitivity property of the type system? Am I just suffering from laziness? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Type Synonyms
Andrew Wagner wagner.andrew at gmail.com writes: If you change your type declarations to 'newtype' declarations, I believe you would get the effect that you want, depending on what you mean by 'equivalent'. In that case, Foo and Bar would essentially be strings, but you could not use either of them in a place where the other is expected, nor where a String is expected. See http://haskell.org/haskellwiki/Newtype for more information. Hope this helps! I wanted to avoid wrapping the string with a constructor. I suppose what I'm really asking for is for each type to implicitly define a 'type class with no methods', and to be able to create new instances of that type class which simply behave as the underlying type. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Where would I find fromInt?
Hi Paul -- The function you want is called fromIntegral, and works for all Integral types. Using it, you can add a type signature to specify what you want to change the number to (Float, Double, other Integral type, etc. Example: fromIntegral (4 :: Int) :: Double 4.0 Hope this helps! -- Tom Harper [EMAIL PROTECTED] +1 949 235 0185 Public Key: http://aftereternity.co.uk/rth.asc On 9/9/07, PR Stanley [EMAIL PROTECTED] wrote: Hi Where would I find the fromInt function, please? Better still, would anyone know how to write a func for converting int to float and vice versa? Thanks, Paul ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Tom Harper [EMAIL PROTECTED] +1 949 235 0185 Public Key: http://aftereternity.co.uk/rth.asc ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Learning advice
No, that book is not outdated. Can you give an example of what's not working for you? On 9/6/07, Chris Saunders [EMAIL PROTECTED] wrote: I wish to learn Haskell. I purchased a book – An Introduction to Functional Programming Systems Using Haskell but I think this might be too outdated. I'm using GHC and it seems that some of the functions used in the book are no longer a part of Haskell. I'm looking for advice on books or tutorials that might be more up to date. So far I'm finding Haskell difficult – I may be too thick. Regards Chris Saunders ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Tom Harper [EMAIL PROTECTED] +1 949 235 0185 Public Key: http://aftereternity.co.uk/rth.asc ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Learning advice
Don't bang your head against a wall too long. Like Brent said, #haskell is quite a good resource. There's always (and I mean ALWAYS) a group of people online at any given time that can answer your questions. On 9/6/07, Chris Saunders [EMAIL PROTECTED] wrote: Thanks to all that responded (I enjoyed very much the story). From the response below I think my thickness is showing too much and I'll try a little harder on my own first. Thanks again, Chris Saunders -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Tom Harper Sent: September-06-07 12:21 PM To: Chris Saunders Cc: haskelll-cafe Subject: Re: [Haskell-cafe] Learning advice No, that book is not outdated. Can you give an example of what's not working for you? -- Tom Harper [EMAIL PROTECTED] +1 949 235 0185 Public Key: http://aftereternity.co.uk/rth.asc -- Tom Harper [EMAIL PROTECTED] +1 949 235 0185 Public Key: http://aftereternity.co.uk/rth.asc ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] expension of fractions
Arie Groeneveld wrote: : | Looking at the result of my rewriting gives me the idea it isn't | Haskelly enough. | | Anyways, here's my interpretation: | | -- period m/n base = (period length, preperiod digits, period digits) | period :: Integer - Integer - Integer - (Int, ([Integer], [Integer])) : Haskelliness I'd be inclined to try using a Rational (from Data.Ratio) and the properFraction function, instead of numerators and denominators and gcd. You could do away with the parts where you subscript a linked list, if you did something with elem and zip and span instead of findIndex and splitAt. Instead of translating Nothing to -1 and Just i to i, you could use the result of findIndex directly in a case expression. Correctness *Main period 8 70 10 (6,([0],[5,7,1,4,2,8])) That should be (6,([1],[1,4,2,8,5,7])). Regards, Tom ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] xkcd #287 NP-Complete
We've seen some nice concise solutions that can deal with the original problem: solve 1505 [215, 275, 335, 355, 420, 580] I'll be a nuisance and bring up this case: solve 150005 [2, 4, 150001] A more scalable solution is to use an explicit heap that brings together all the ways to get to each partial sum. I coded one using Data.Map, but it's a bit long-winded and ugly. Perhaps a purpose-built heap monad would make it more elegant... as long as it could be reused elsewhere. Just musing. :-) - Tom ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Functional dependencies *not* part of the next Haskell standard?
| I think the implementation is some 90% complete though, in GHC head. | Certainly you can write many associated types programs already -- the | missing part is finishing off associated type synonyms, iirc. ...and we have a working implementation of that too, thanks to Tom Schrijvers. It's not in the HEAD yet, but it will be in a few weeks. so it will be a part of 6.8? great news! afaiu, ATS, rather than AT, is direct substitution for FD? Functional dependencies desugar to indexed type families, an extension of the original associated, in GHC head already. For the full story, see the wiki page. http://haskell.org/haskellwiki/GHC/Indexed_types which includes an example of porting functional dependencies to associated types http://haskell.org/haskellwiki/GHC/Indexed_types#A_associated_type_synonym_example It's really simple to replace a functional dependency with a type function. A class declaration class C a b | a - b becomes: class FD a ~ b = C a b where type FD a and an instance instance C [x] x becomes instance C [x] x where type FD [x] = x That's it: only class and instance declarations have to be modified. Now you can start to drop dependent parameters, if you want. There are a few examples in my slides as well (if you don't mind the pptx): http://www.cs.kuleuven.be/~toms/Research/talks/Tyfuns.pptx Cheers, Tom -- Tom Schrijvers Department of Computer Science K.U. Leuven Celestijnenlaan 200A B-3001 Heverlee Belgium tel: +32 16 327544 e-mail: [EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: To yi or not to yi, is this really the question? A plea for a cooperative, ubiquitous, distributed integrated development system.
On Thu, 21 Jun 2007, Pasqualino 'Titto' Assini wrote: Thanks for the explanation. But, doesn't this simply mean that the correct signature would be: serialize :: (Int - Int) - IO String to take in account the fact that serialise really use 'external' information that is not in the domain of pure Haskell functions? I'm afraid not. The beauty of the IO monad is that it permits equational reasoning over I/O operations. E.g. because of the definition print = putStrLn . show the compiler can freely inline calls to print. Although there's I/O involved, equational reasoning is still valid: the inlined call will behave in the same way as the original code. Hence, the compiler does not have to be aware of IO and treat it in a different way. Your serialize function does not have that property. You don't want its argument to be inlined or otherwise replaced with an equivalent expression. Tom Having serialize in the IO monad would do no harm as usually one serialise precisely to output a value :-) So, is it correct to conclude that there is no theoretical reason why Haskell cannot have a built-in reification/serialisation facility? titto On Wednesday 20 June 2007 17:05:04 apfelmus wrote: Pasqualino 'Titto' Assini wrote: Is there any fundamental reasons why Haskell functions/closures cannot be serialised? I believe that this is precisely what the distributed version of GHC used to do. Most languages, even Java, have a reflection capability to dynamically inspect an object. It is surprising that Haskell doesn't offer it. Inspecting functions is not referentially transparent. In Haskell, function equality is extensional, i.e. two functions are equal when their results are equal on all arguments. Intensional equality would mean that functions are equal when they have the same representation. If you allow a function serialize :: (Int - Int) - String that can give different results on intensionally different functions, you may not expect equations like f (*3) == f (\n - n+n+n) to hold anymore (because f might inspect its argument). Also, having serialize somehow check whether intensionally different arguments are extensionally the same and should have a unique serialization is no option because this problem is undecidable. Regards, apfelmus ___ 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 -- Tom Schrijvers Department of Computer Science K.U. Leuven Celestijnenlaan 200A B-3001 Heverlee Belgium tel: +32 16 327544 e-mail: [EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Haskell serialisation, was: To yi or not to yi...
On Thu, 21 Jun 2007, Pasqualino 'Titto' Assini wrote: Hi Tom, On Thursday 21 June 2007 08:59:42 Tom Schrijvers wrote: On Thu, 21 Jun 2007, Pasqualino 'Titto' Assini wrote: Thanks for the explanation. But, doesn't this simply mean that the correct signature would be: serialize :: (Int - Int) - IO String to take in account the fact that serialise really use 'external' information that is not in the domain of pure Haskell functions? I'm afraid not. The beauty of the IO monad is that it permits equational reasoning over I/O operations. E.g. because of the definition print = putStrLn . show the compiler can freely inline calls to print. Although there's I/O involved, equational reasoning is still valid: the inlined call will behave in the same way as the original code. Hence, the compiler does not have to be aware of IO and treat it in a different way. Your serialize function does not have that property. You don't want its argument to be inlined or otherwise replaced with an equivalent expression. Is it so? I understand that, depending on what the compiler does the result of : do let f = (*) 2 print $ serialise f might differ as, for example, the compiler might have rewritten f as \n - n+n. But, why would that make equational reasoning on serialise not valid? Isn't that true for all functions in the IO monad that, even when invoked with the same arguments, they can produce different results? Not if you take the ``state of the world to be part of the arguments. If two programs behave differently for the same arguments and the same state of the world, then they're not equivalent. You do want your compiler to preserve equivalence, don't you? Tom -- Tom Schrijvers Department of Computer Science K.U. Leuven Celestijnenlaan 200A B-3001 Heverlee Belgium tel: +32 16 327544 e-mail: [EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Haskell serialisation, was: To yi or not to yi...
Tom Schrijvers wrote: I understand that, depending on what the compiler does the result of : do let f = (*) 2 print $ serialise f might differ as, for example, the compiler might have rewritten f as \n - n+n. But, why would that make equational reasoning on serialise not valid? Isn't that true for all functions in the IO monad that, even when invoked with the same arguments, they can produce different results? Not if you take the ``state of the world to be part of the arguments. If two programs behave differently for the same arguments and the same state of the world, then they're not equivalent. You do want your compiler to preserve equivalence, don't you? You can put the internal representation of the argument into the state of the world. That wouldn't make a difference. If, from the pure Haskell point of view we can't tell the difference between two expressions that denote the same function, then operations in the IO monad should not be able to do so either. Otherviews a whole lot of program transformations based on rewriting of expressions would be invalid. How do you account for that? Tom -- Tom Schrijvers Department of Computer Science K.U. Leuven Celestijnenlaan 200A B-3001 Heverlee Belgium tel: +32 16 327544 e-mail: [EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Haskell serialisation, was: To yi or not to yi...
On Thursday 21 June 2007, Tom Schrijvers wrote: That wouldn't make a difference. If, from the pure Haskell point of view we can't tell the difference between two expressions that denote the same function, then operations in the IO monad should not be able to do so either. This doesn't make any sense to me. IO is a non-determinism monad (among many other things). That's already true --- randomIO is one example; Control.Exception.evaluate is another (and is already dependent on the particular compilation choices made). I think of Haskell `values' as sets of legal representations anyway --- why shouldn't serialize be free to make a non-deterministic choice from among those sets, just like evaluate can make a non-deterministic choice from the set of exceptions an expression can throw? Good point. I agree, if the specification is non-deterministic, this should be alright. Tom -- Tom Schrijvers Department of Computer Science K.U. Leuven Celestijnenlaan 200A B-3001 Heverlee Belgium tel: +32 16 327544 e-mail: [EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Perl-style numeric type
On 6/19/07, Brent Yorgey [EMAIL PROTECTED] wrote: I've started developing a library to support a Perl-style numeric type that does the right thing without having to worry too much about types. But before I get too far (it looks like it will be straightforward yet tedious to implement), I thought I would throw the idea out there and see if anyone knows of anything similar that has already been done before Do you know about Pugs? http://www.pugscode.org/ Hope this helps! --Tom Phoenix ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Construct all possible trees
*Andrew Coppin wrote: * | I'm trying to construct a function | | all_trees :: [Int] - [Tree] | | such that all_trees [1,2,3] will yield : If you write a helper function that takes an N element list, and returns all 2^N ways of dividing those elements into 2 lists, e.g. splits ab -- [(ab,),(b,a),(a,b),(,ab)] then you can use it both for dividing the initial list into kept and discarded elements, and for dividing a list between a left subtree and a right subtree. Regards, Tom ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] LaTeX
I got this from the Literate Haskell page on the Emacs Wiki[1]: \usepackage{listings} \lstloadlanguages{Haskell} \lstnewenvironment{code} {\lstset{}% \csname [EMAIL PROTECTED] {\csname [EMAIL PROTECTED] \lstset{ basicstyle=\small\ttfamily, flexiblecolumns=false, basewidth={0.5em,0.45em}, literate={+}{{$+$}}1 {/}{{$/$}}1 {*}{{$*$}}1 {=}{{$=$}}1 {}{{$$}}1 {}{{$$}}1 {\\}{{$\lambda$}}1 {-}{{$\rightarrow$}}2 {=}{{$\geq$}}2 {-}{{$\leftarrow$}}2 {=}{{$\leq$}}2 {=}{{$\Rightarrow$}}2 {\ .}{{$\circ$}}2 {\ .\ }{{$\circ$}}2 {}{{}}2 {=}{{=}}2 {|}{{$\mid$}}1 } That replaces various strings (including ++) with their symbol equivalents and generally makes things quite pretty. Tom [1]: http://haskell.org/hawiki/LiterateProgramming On 6/8/07, Andrew Coppin [EMAIL PROTECTED] wrote: Does anybody know what the magical LaTeX command is to turn (say) ++ into two overprinted pluses? (As seems to be fashionable...) ___ 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] Just curios
On Mon, 11 Jun 2007, Stephen Forrest wrote: On 6/10/07, Brandon S. Allbery KF8NH [EMAIL PROTECTED] wrote: You're pretty close, actually :) Names derived from Hebrew were fairly common in the Bible belt back when he was born. (Haskell from , wisdom. I half suspect Curry has a Biblical origin as well, from .) Bible belt? Curry was born in Millis, Massachusetts, and grew up in Boston. The word Haskell seems to occur much more frequently as a surname, originating in the British Isles. It seems more plausible that he got the name Haskell from some relative or family friend somewhere than ascribing a Hebrew origin for his name. I found this: HASKEL: Hebrew name meaning intellect. Variant, Haskell, exists. in a list name explanations: http://www.smcm.edu/users/saquade/names.html Tom -- Tom Schrijvers Department of Computer Science K.U. Leuven Celestijnenlaan 200A B-3001 Heverlee Belgium tel: +32 16 327544 e-mail: [EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Switch optimization
Stefan O'Rear wrote: | On Mon, Jun 11, 2007 at 09:43:17AM +1000, Thomas Conway wrote: : | codeLen 127 = 0 | codeLen 128 = 1 | ... | codeLen 255 = 8 | | Now, compiling with ghc 6.6.1 and -O3, I see that it generates a long | chain of conditional branches. : That's deeply tied in with Num being a subclass of Eq, isn't it? Pattern matching for /non-numeric/ data constructors should be more direct, at any optimisation level, thanks to the taglessness of the STG machine. | I'd suggest learning how to hack on GHC, I get a chain of branches even | at the maximum optimization setting. Hackers are always appreciated! Such a GHC hack may have to be limited to some known, standard numeric types. User-defined numeric types may not provide anything that you can use to look up a jump table. How would an array go, as a user-level optimisation? Regards, Tom ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] New book: Real-World Haskell!
I really hope they choose the flying squirrel. On 5/23/07, Dan Weston [EMAIL PROTECTED] wrote: What power animal have you chosen for the cover of your O'Reilly book? Alas, most of the good ones are gone already! Donald Bruce Stewart wrote: Bryan O'Sullivan, Don Stewart and John Goerzen are pleased, and frankly, very excited to announce that were developing a new book for O'Reilly, on practical Haskell programming. The working title is Real-World Haskell. The plan is to cover the major techniques used to write serious, real-world Haskell code, so that programmers can just get to work in the language. By the end of the book readers should be able to write real libraries and applications in Haskell, and be able to: * design data structures * know how to write, and when to use, monads and monad transformers * use Haskells concurrency and parallelism abstractions * be able to write parsers for custom formats in Parsec. * be able to do IO and binary IO of all forms * be able to bind Haskell to foreign functions in C * be able to do database, network and gui programming * know how to do exception and error handling in Haskell * have a good knowledge of the core libraries * be able to use the type system to track and prevent errors * take advantage of tools like QuickCheck, Cabal and Haddock * understand advanced parts of the language, such as GADTs and MPTCs. That is, you should be able to just write Haskell! The existing handful of books about Haskell are all aimed at teaching programming to early undergraduate audiences, so they are ill-suited to people who already know how to code. And while theres a huge body of introductory material available on the web, you have to be both tremendously motivated and skilled to find the good stuff and apply it to your own learning needs. The time has come for the advanced, practical Haskell book. Heres the proposed chapter outline: 1. Why functional programming? Why Haskell? 2. Getting started: compiler, interpreter, values, simple functions, and types 3. Syntax, type system basics, type class basics 4. Write a real library: the rope data structure, cabal, building projects 5. Typeclasses and their use 6. Bringing it all together: file name matching and regular expressions 7. All about I/O 8. I/O case study: a DSL for searching the filesystem 9. Code case study: barcode recognition 10. Testing the Haskell way: QuickCheck 11. Handling binary files and formats 12. Designing and using data structures 13. Monads 14. Monad case study: refactoring the filesystem seacher 15. Monad transformers 16. Using parsec: parsing a bioinformatics format 17. Interfacing with C: the FFI 18. Error handling 19. Haskell for systems programming 20. Talking to databases: Data.Typeable 21. Web client programming: client/server networking 22. GUI programming: gtk2hs 23. Data mining and web applications 24. Basics of concurrent and parallel Haskell 25. Advanced concurrent and parallel programming 26. Concurrency case study: a lockless database with STM 27. Performance and efficiency: profiling 28. Advanced Haskell: MPTCs, TH, strong typing, GADTs 29. Appendices We're seeking technical reviewers from both inside and outside the Haskell community, to help review and improve the content, with the intent that this text will become the standard reference for those seeking to learn serious Haskell. If you'd like to be a reviewer, please drop us a line at [EMAIL PROTECTED], and let us know a little about your background and areas of interest. Finally, a very exciting aspect of this project is that O'Reilly has agreed to publish chapters online, under a Creative Commons License! Well be publishing chapters incrementally, and seeking feedback from our reviewers and readers as we go. You can find more details and updates at the following locations: * The web site, http://www.realworldhaskell.org/blog/welcome/ * The authors, http://www.realworldhaskell.org/blog/about/ * The blog, http://www.realworldhaskell.org/blog/ -- Bryan O'Sullivan, Don Stewart and John Goerzen. ___ 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 -- Tom Harper Computer Science Major '07 Syracuse University +1 949 235 0185 Public Key: http://aftereternity.co.uk/rth.asc ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Scope of type variables in associated types
Ok, thanks for the clarification. One final question then, how could I rewrite the following in associated types: class OneStep a b | a - b instance OneStep (Cons v t) t class TwoStep a b | a - b instance (OneStep a b, OneStep b c) = TwoStep a c If the fundep and b is dropped then I get: class OneStep a data OS a :: * instance OneStep (Cons v t) data OS (Cons v t) = t data constructor missing !!! class TwoStep a data TS a :: * instance (OneStep a, OneStep b) = TwoStep a This last one can't be right, as I can't express the fact that the OS in OneStep a provides the link with OneStep b. So is there a way to achieve this sort of chaining with associated types? You'd have to write class OneStep a data OS a :: * instance OneStep (Cons v t) data OS (Cons v t) = OSC t class TwoStep a data TS a :: * instance (OneStep a, OneStep (OS a)) = TwoStep a where type TS a = TSC (OS (OS a)) which seems rather awkward with all these additional data type constructors. You'd be better off with associated type synonyms: class OneStep a type OS a :: * instance OneStep (Cons v t) type OS (Cons v t) = t class TwoStep a type TS a :: * instance (OneStep a, OneStep (OS a)) = TwoStep a type TS a = OS (OS a) which are currently under development. -- Tom Schrijvers Department of Computer Science K.U. Leuven Celestijnenlaan 200A B-3001 Heverlee Belgium tel: +32 16 327544 e-mail: [EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell on OS X
I use Aquamacs with the haskell mode from haskell.org. MacPorts wasn't being useful with ghc, I downloaded binaries, and they work fine. On 5/19/07, Johan Tibell [EMAIL PROTECTED] wrote: I just switched to OS X and was wondering if someone would like to share their setup. Install binaries from haskell.org or Mac Ports? Which emacs build? etc Johan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Tom Harper Computer Science Major '07 Syracuse University +1 949 235 0185 Public Key: http://aftereternity.co.uk/rth.asc ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] global variables
You can also use mutable variables (MVars) found in Control.Concurrent.MVar http://haskell.org/ghc/docs/latest/html/libraries/base/Control-Concurrent-MVar.html They might work depending on your implementation. The reading and writing of MVars returns IO actions. On 5/17/07, Dougal Stanton [EMAIL PROTECTED] wrote: On 17/05/07, Eric [EMAIL PROTECTED] wrote: H|i, Does anyone know of a simple and straightforward way to use global variables in Haskell? You can pass around an environment with the State or Reader monads (read/write and read-only respectively). If you want to do IO with the data you'll probably need the transformer equivalents: StateT or ReaderT. I think there are some hackish ways of making IO variables but I don't know how that's done. I'd imagine it's frowned on from a stylistic point of view, too... D. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Tom Harper Computer Science Major '07 Syracuse University +1 949 235 0185 Public Key: http://aftereternity.co.uk/rth.asc ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ambiguous type variables at MPTC
If f2 is legal, why if f3 illegal? For some usage site of f3, the constraint C String b might allow b to be resolved given whatever instances of C are in effect. Is there a motivation for these behaviors? Are these sorts of cases discussed in the CHR/FD paper that motivated the coverage condition (which I have yet to read)? It should be possible to resolve the constraints from the types in the signature. That rules out f1 and f3. For f2, given a type for a, say Int, not just any odd instance for b will do, say instance C Int Bool GHC says: No instance for (C Int b) arising from use of `f2' at Q.hs:30:6-9 Possible fix: add an instance declaration for (C Int b) In the expression: f2 x In the definition of `f': f x = f2 x No, it has to be an instance for all possible types b: instance C Int b So, you can only call f2 with types a for which the instance C a b is completely independent of b. There is no ambiguity. Tom -- Tom Schrijvers Department of Computer Science K.U. Leuven Celestijnenlaan 200A B-3001 Heverlee Belgium tel: +32 16 327544 e-mail: [EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] hash of a lazy bytestring?
On Sun, 13 May 2007, David Roundy wrote: I was just contemplating hashes, and it occurred to me that it would be nice to be able to compute the hash of a lazily constructed bytestring and lazily consume its output without requiring the whole string to ever be in memory. Or in general, it'd be nice to be able to perform two simultaneous consumptions of a lazy list without requiring that the entire list be stored. How about reading the same file twice? do l1 - readFile foo l2 - readFile foo let len = length l1 writeFile bar l2 ... Another solution would be loop fusion: do l - readFile foo len - writeFileAndComputeLength bar l ... A compiler might be able to do that for you. Tom -- Tom Schrijvers Department of Computer Science K.U. Leuven Celestijnenlaan 200A B-3001 Heverlee Belgium tel: +32 16 327544 e-mail: [EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Monad pronounced like gonad?
Hahahah, it's pronounced the way you've been saying it =) On 5/10/07, Dan Weston [EMAIL PROTECTED] wrote: I've been pronouncing monad like gonad (moh-nad), but it occurs to me that it might be pronounced like monoid (mah-nad). Is there an official way to pronouce this word - maybe with a Scottish accent? :) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Tom Harper Computer Science Major '07 Syracuse University +1 949 235 0185 Public Key: http://aftereternity.co.uk/rth.asc ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Vanishing polymorphism
To cut a long story short, could someone explain why: :t negate negate :: forall a. (Num a) = a - a :t let f (fn :: forall a . Num a = a - a) r s = (fn r, fn s) in f negate let f (fn :: forall a . Num a = a - a) r s = (fn r, fn s) in f negate :: forall r s. (Num r, Num s) = r - s - (r, s) but :t let f r s = (return negate) = (\fn - return (fn r, fn s)) in f let f r s = (return negate) = (\fn - return (fn r, fn s)) in f :: forall a (m :: * - *). (Num a, Monad m) = a - a - m (a, a) and :t let f r s = (return negate) = (\(fn::forall n . (Num n) = n - n) - return (fn r, fn s)) in f interactive:1:35: Couldn't match expected type `a - a' against inferred type `forall n. (Num n) = n - n' In the pattern: fn :: forall n. (Num n) = n - n In a lambda abstraction: \ (fn :: forall n. (Num n) = n - n) - return (fn r, fn s) In the second argument of `(=)', namely `(\ (fn :: forall n. (Num n) = n - n) - return (fn r, fn s))' I.e. why does the polymorphism get destroyed? Unless annotated otherwise, functions destroy the polymorphism of their arguments. In your first example f's argument is annotated to be polymorphic, hence you can call it with two different types. In your second example, the lambda abstraction does not declare it expects a polymorphic argument. So you get a monomorhpic one. Neither does return or =. So that all works fine. In your third example, return destroys the polymorphism of negate. becomes monomorphic for some a, the a - a without forall. = is happy with the monomorphism. Then it is received by the lambda abstraction that expects a polymorphic type and causes the error. You can read more about this in the paper: Practical type inference for arbitrary-rank types Simon Peyton Jones, Dimitrios Vytiniotis, Stephanie Weirich, and Mark Shields http://research.microsoft.com/~simonpj/papers/higher-rank/index.htm Basically, it comes down to the fact that preserving polymorphism is too hard for type inference, unless you the prorgrammer provide sufficient declarations for it. Cheers, Tom -- Tom Schrijvers Department of Computer Science K.U. Leuven Celestijnenlaan 200A B-3001 Heverlee Belgium tel: +32 16 327544 e-mail: [EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Vanishing polymorphism
On Tue, 8 May 2007, David House wrote: On 08/05/07, Matthew Sackman [EMAIL PROTECTED] wrote: :t let f r s = (return negate) = (\(fn::forall n . (Num n) = n - n) - return (fn r, fn s)) in f interactive:1:35: Couldn't match expected type `a - a' against inferred type `forall n. (Num n) = n - n' In the pattern: fn :: forall n. (Num n) = n - n In a lambda abstraction: \ (fn :: forall n. (Num n) = n - n) - return (fn r, fn s) In the second argument of `(=)', namely `(\ (fn :: forall n. (Num n) = n - n) - return (fn r, fn s))' I.e. why does the polymorphism get destroyed? Here fn is bound by a lambda abstraction, and is therefore monomorphic. I can't find anything in the Report about that, This won't be in the Haskell 98 report. I have to enable -fglasgow-exts in GHCi to get this even parsed. Tom -- Tom Schrijvers Department of Computer Science K.U. Leuven Celestijnenlaan 200A B-3001 Heverlee Belgium tel: +32 16 327544 e-mail: [EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Bloom Filter
Hi Andrew, Thanks for the comments, it really helps to have someone else's opinion on my code. I'll be applying what you've said as soon as I get a chance and I'm sure I'll have some more questions then. I'll certainly look more closely at the Set interface and try and duplicate all the parts which make sense. I've been using Darcs for a while with non-haskell projects as well as this project, however it seems that cabal strips out the darcs meta-data when making up a distribution tar file. Is there an option to have it include the darcs stuff? it seems like it could be quite useful and I can't really see a downside. If you're interested the Darcs repository is at: http://www.almostobsolete.net/bloom/ Tom On 5/1/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: G'day. Quoting tom [EMAIL PROTECTED]: I'm pretty new to Haskell, I've been working on a Bloom filter[1] implementation as a learning exercise. Excellent! Sounds like a fun test. I'd really appreciate it if someone more experienced would comment on the code. I'm sure there's plenty of places where I'm doing things in silly or overly complex ways. Sure. All in all, very well done. It works, and it looks pretty efficient. My quibbles are mostly stylistic or syntactic in nature. Please understand that the relative triviality of my quibbles is a sign that there are really no major problems. This is not a criticism, but more an advertisement: What are you using for source control here? Darcs is nice, and as a bonus, it's trivially browsable from a web browser, which saves downloading and unpacking. General comments: You overuse parentheses. A lot. Definitions like this: ary = (listArray (0, wordc-1) (repeat 0)) don't need parentheses around them, and just add to the general noise level. And (.. ((size b)-1)) is much more cleanly expressed as (.. (size b - 1)). Rather than carrying around a hash function, it might be better to use a type class: class BloomHash k where bloomHash :: k - [Word8] In wordsize: You don't need to hard-code this. You can use: wordsize = bitSize (undefined::Word32) -- Or Int, of course! bitSize is defined in Data.Bits. In splitup: I got a bit confused by the local binding names. It's usual, especially in generic code, to use xs, ys etc for a list of x and y. Something like this might be more idiomatic: splitup n xs = let (xs1, xs2) = splitAt n xs in xs1 : splitup n xs2 In indexes: (fromIntegral $ x `div` wordsize, fromIntegral $ x .. (wordsize-1)) Seems intuitively wasteful. Either use divMod or bit operations. Similarly, (hashfunc b) key is the same as hashfunc b key. But even better is: split bytecount . hashfunc b $ key That makes it obvious that it's a pipeline of functions applied to the key. This looks cool: bytes2int = foldr ((. (256 *)) . (+)) 0 . (map toInteger) but I'm not smart enough to parse it. This is both more readable and shorter: bytes2int = foldr (\x r - r*256 + fromInteger x) 0 Integer log2's are probably better done using integers only, or at least abstracted out into a separate function. In bloom: Function guards are your friends! This: bloom hf sz hc = if condition then b else error Badness is almost always better expressed as: bloom hf sz hc | condition = b | otherwise = error Badness You can now inline b. (I can see why you put it in a where clause; now you don't have to.) wordc, again, only needs integral arithmetic: wordc = ceiling ((fromIntegral a) / (fromIntegral b :: Double)) is more or less: wordc = (a+b-1) `div` b And drop the parentheses around the definition of ary. In add: Try to use function names that are close to names in existing libraries, like Data.Set. insert sounds better here. Also, rather than this: add :: Bloom a - a - Bloom a a better argument order is this: insert :: a - Bloom a - Bloom a That way, you can use it with foldr. In test: Again, probably misnamed. Data.Set calls this member. And again, arguably the wrong argument ordering. Once again, well done. Cheers, Andrew Bromage ___ 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] Bloom Filter
Hi all, I'm pretty new to Haskell, I've been working on a Bloom filter[1] implementation as a learning exercise. I'd really appreciate it if someone more experienced would comment on the code. I'm sure there's plenty of places where I'm doing things in silly or overly complex ways. I've packaged it all with Cabal because I wanted to see how that all worked, I don't think it's ready for release yet! I would like to at some point get it polished up and release it if anyone thinks it might be useful. You can download it at: http://www.almostobsolete.net/bloom-0.0.tar.gz I've also put the Haddock docs for it online at: http://www.almostobsolete.net/doc/html/Data-yBloom.html All comments will be very much appreciated :p Thanks Tom [1] There's a nice description of what a Bloom filter is here: http://www.cs.wisc.edu/~cao/papers/summary-cache/node8.html ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Creating pseudo terminals
On 4/29/07, Georg Sauthoff [EMAIL PROTECTED] wrote: On 2007-04-29, Tom Hawkins [EMAIL PROTECTED] wrote: Hi, [..] I haven't done this before in any language, so any tips would be appreciated. From what I gather, a call to posix_openpt or openpty returns a master and a slave, or alternatively opening /dev/ptmx followed by calls to grantpt and unlockpt. well, then I suggest 'Stevens, Advanced programming in the unix environment' for basic pseudo terminal programming. Thanks for the reference. Does Haskell's standard library support pseudo terminals, or will I have to write foreign interfaces for grantpt and unlockpt? -Tom ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Creating pseudo terminals
How can I create a pseudo terminal in Linux with Haskell? Nothing is jumping out at me in the standard library. I haven't done this before in any language, so any tips would be appreciated. From what I gather, a call to posix_openpt or openpty returns a master and a slave, or alternatively opening /dev/ptmx followed by calls to grantpt and unlockpt. I'm building a load balancing and sharing system similar to Platform's LSF. The pseudo terminal is for interactive jobs running on a remote machine. Thanks for any help! -Tom ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Compilling GHC on Vista
I still get the same message even with these instructions. I guess it may be due to some Vista security checking... Do you still get the same error message in your config.log now? Or a different one? There is also an error on Vista with checking whether a file is executable. I don't know whether there's already a solution for that in the repository? Tom Cheers, Monique On 4/24/07, Simon Marlow [EMAIL PROTECTED] wrote: Tom Schrijvers wrote: Here's the more complete error message: configure:3321: checking for C compiler default output file name configure:3348: c:/MinGW/bin/gccconftest.c 5 ld: /mingw/lib/crt2.o: No such file: No such file or directory configure:3351: $? = 1 configure:3389: result: configure: failed program was: configure:3396: error: C compiler cannot create executables See `config.log' for more details. Do make sure that MingW's bin/ and libexec/gcc/mingw32/3.4.2/ are the very first two in your path. I get the same error message if I don't do that. Hi Tom - would you mind adding the right incantation to the Vista instructions at the top of http://hackage.haskell.org/trac/ghc/wiki/Building/Windows? Cheers, Simon -- __ Monique Monteiro, MSc MCP .NET Framework 2.0 / SCJP / IBM OOAD Project Manager Recife Microsoft Innovation Center +55 81 34198137 http://www.cin.ufpe.br/~mlbm http://thespoke.net/blogs/moniquelouise/default.aspx [EMAIL PROTECTED] MSN: [EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Tom Schrijvers Department of Computer Science K.U. Leuven Celestijnenlaan 200A B-3001 Heverlee Belgium tel: +32 16 327544 e-mail: [EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Compilling GHC on Vista
I'm trying to compile GHC on Windows Vista, but I encountered the following error when running ./configure --host=i386-unknown-mingw32 --with-gcc=c:/MinGW/bin/gcc: configure: error: C compiler cannot create executables See `config.log' for more details. ./configure: line 3404: cannot create temp file for here document: No such file or directory ./configure: line 3441: cannot create temp file for here document: No such file or directory Has anyone any idea about what may be happening? Monique, What does the config.log say? Are you able to run the MingW's gcc compiler yourself on a simple C program? I had a similar error, cause by the fact that gcc.exe cannot find cc1.exe, which is in MingW/libexec/gcc/mingw32/3.4.2/. I had to add it to my PATH. Cheers, Tom -- Tom Schrijvers Department of Computer Science K.U. Leuven Celestijnenlaan 200A B-3001 Heverlee Belgium tel: +32 16 327544 e-mail: [EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Compilling GHC on Vista
On Mon, 23 Apr 2007, Monique Monteiro wrote: Tom, On 4/23/07, Tom Schrijvers [EMAIL PROTECTED] wrote: What does the config.log say? Are you able to run the MingW's gcc compiler yourself on a simple C program? I had a similar error, cause by the fact that gcc.exe cannot find cc1.exe, which is in MingW/libexec/gcc/mingw32/3.4.2/. I had to add it to my PATH. I did the same, but it still doesn't work... Here is config.log: Here's the more complete error message: configure:3321: checking for C compiler default output file name configure:3348: c:/MinGW/bin/gccconftest.c 5 ld: /mingw/lib/crt2.o: No such file: No such file or directory configure:3351: $? = 1 configure:3389: result: configure: failed program was: configure:3396: error: C compiler cannot create executables See `config.log' for more details. Do make sure that MingW's bin/ and libexec/gcc/mingw32/3.4.2/ are the very first two in your path. I get the same error message if I don't do that. Tom -- Tom Schrijvers Department of Computer Science K.U. Leuven Celestijnenlaan 200A B-3001 Heverlee Belgium tel: +32 16 327544 e-mail: [EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] ANN: Atom - Yet another Haskell HDL
Hi, Haskell has a rich history of embedded hardware description languages. Here's one more for the list. Inspired by the work of Arvind, Hoe, and all the sharp folks at Bluespec, Atom is a small HDL that compiles conditional term rewriting systems down to Verilog RTL. In Atom, a circuit description is composed of a set of state elements (registers) and a set of rules. Each rule has two components: an enabling condition and a collection of actions, or state updates. When a rule is enabled, it's actions may be selected to execute atomically. In contrast to Verilog always blocks, multiple rules can write to the same state element. Here's an enabled counter in Atom: counter :: Int - Signal - System Signal counter width enable = do count - reg count width 0 rule updateCount $ do when enable count == value count +. one width return $ value count Enjoy! http://funhdl.org/ -Tom A few details: The Atom compiler attempts to maximize the number of rules that can execute in a given clock cycle without breaking the semantics of one-rule-at-a-time. For simplicity, rules are assigned a global, linear priority. Data dependencies between rules form a graph. A acyclic graph is ideal, because all rules become sequentially composable. The compiler attempts to order the rules to minimize the number of edges feeding back from lower to higher priority rules. This is equivalent to the feedback arc set problem. (Atom's FAS optimization is pretty poor at the moment.) In a rule-data dependency graph, many of the edges are irrelevent because pairs of rules are often mutually exclusive, ie. can not be enabled at the same time. MiniSat is used to hunt and prune edges from mutually exclusive rules. By only looking back to primary inputs and registers, the SAT procedure is not guaranteed to find all mutually exclusive rules, but it does a pretty good job. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Haskell for Accessibility
I love programming in Haskell, yet even its concise expressions have not saved my tendons from chronic RSI. Has anyone put any thought into building an accessible Haskell development interface for those who may not be able to use a keyboard? One inspirational program is Dasher (http://www.inference.phy.cam.ac.uk/dasher/). Not only is it godsend for people with a wide range of disabilities, Dasher is also a lot of fun to use. Though Dasher is good at general text entry, it's not well suited for programming. However, combining Dasher's statistical inference with Haskell's type inference might yield a graphical, cursor driven interface even more efficient than the conventional keyboard. Is there interested in such a project? I don't have the expertise or typing strength (pun intended) to go it alone, but I could lend a hand. Here are a few random ideas: - A tree viewer to navigate and manage directories, modules, module declarations, and expressions. Similar to a directory explorer, nodes in the tree can be collapsed and expanded. Collapsed module definitions would display the type annotation, while hiding the definition. - Another interface for composing expressions. This interface could be similar to Dasher, but use both statistical inference and type inference to weight and prune the decision tree. The expression composer interface could directly assemble the abstract syntax tree, thus eliminating the need for whitespace and ()s. Of course, the tree viewer would pretty print all expressions in the familiar Haskell layout. - The development environment could be hosted as a web server, delivering SVG and minimal JavaScript for the client-side interface, allowing Haskell program development from any web browser with a 2 button mouse -- head mounted or eye tracked, of course. The client-server architecture would allow developers to concurrently work from the same source code. - From the tree viewer, click any expression to view the compiler's inferred type, with the ability to turn any inferred type into a concrete type annotation. And the ability to compare inferred types to type annotations. Type violations highlighted in red. - Variable references would not have to be explicitly spelled out. Instead, variables could be selected from either the tree viewer or expression composer, forming a hard link. When a variable's name changes, all references could be automatically updated. When an expression is either moved or copied into a new lexical scope, the variable references could be automatically rebound to variable definitions in the new scope. Unmatched referenced names and ambiguous names would be highlighted in red. -Tom ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Leaves of a Tree
Hello, Any recommendations for speeding up extracting the set of leaves from a tree? data Tree = Branch Tree Tree | Leaf Int deriving (Eq, Ord) My slow, naive function: leaves :: Tree - Set Int leaves (Leaf n) = singleton n leaves (Branch left right) = union (leaves left) (leaves right) In my case, many of the branches in the tree are the same. I suspect the fixed point operation mentioned in the thread speeding up fibonacci with memoizing is applicable, but I'm having a tough time making the connection. -Tom ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Leaves of a Tree
On 2/21/07, Chad Scherrer [EMAIL PROTECTED] wrote: Tom, I think inserting elements would be a lot faster than multiple unions. I would try: leafList :: Tree - [Int] leafList (Leaf n) = [n] leafList (Branch left right) = leafList left ++ leafList right leaves = fromList . leafList If you're writing many functions on Trees (or maybe even if you're not), you might consider writing a fold function and putting leafList in terms of this. Do you have experience with folds? Folding was my first approach: leaves :: Tree - Set Int leaves tree = accumLeaves Set.empty tree accumLeaves :: Set Int - Tree - Set Int accumLeaves set (Leaf n) = insert n set accumLeaves set (Branch l r) = foldl accumLeaves set [l,r] However, with this approach I quickly ran out of stack space. I found this odd, since I thought this program was tail recursive and shouldn't be using the stack. My next attempt was to use some form of memorization. Since many of the branches in my trees are equal, memorization should prevent following branches that have already been calculated. My question is, what is the best way to transform the original function to incorporate memorization? -Tom My slow, naive function: leaves :: Tree - Set Int leaves (Leaf n) = singleton n leaves (Branch left right) = union (leaves left) (leaves right) In my case, many of the branches in the tree are the same. I suspect the fixed point operation mentioned in the thread speeding up fibonacci with memoizing is applicable, but I'm having a tough time making the connection. -Tom ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Can't figure out how to show for type Int - (Int, Int)
Typing up and running (via Hugs) the examples in Wadler's excellent Monads for functional programming (here: http://homepages.inf.ed.ac.uk/wadler/papers/marktoberdorf/baastad.pdf) I hit the inevitable show function error: ERROR - Cannot find show function for: *** Expression : eval answer *** Of type: Int - (Int,Int) I can find lots of nice text about extending data for show (including the miraculous Deriving) but... I'm showing my Haskell newbie roots by utterly failing to understand how to do this of a higher-order type (my best guess for the right term for the type Int - (Int, Int)). It'd be a big help if somebody could tell me either: a) It's obvious, you moron, just insert Haskell code here or b) It's impossible, you moron, you're trying to violate the insert Haskell rule here Here' my code: data Term = Con Int | Div Term Term type M a = State - (a, State) -- higher-order type, e.g. function type type State = Int -- type synonym eval :: Term - M Int eval (Con a) x = (a, x) eval (Div t u) x = let (a, y) = eval t x in let (b, z) = eval u y in (a `div` b, z + 1) answer, error :: Term answer = (Div(Div(Con 1972)(Con 2))(Con 23)) error = (Div(Con 1)(Con 0)) I get the ERROR message when I type eval answer at the Hugs prompt. Thanks! Tom Titchener ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Post mesg
On 11/1/06, Farida Mishra [EMAIL PROTECTED] wrote: i would like to post mesg this list Your wish has been granted. Cheers! --Tom Phoenix ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] function result caching
On 10/12/06, Silviu Gheorghe [EMAIL PROTECTED] wrote: I'd like to know if the results are cached by the compiler Hardly ever, as I understand things. if they are not I'd like to know what is the best way to cache them manually, and where can I read more about this, and the optimizations the compiler does, because I've searched the web before and i found very little on this topic. You need to search for the word memoize (or memoise). Here's a page about a memo function for GHC. http://www.haskell.org/ghc/docs/6.4.2/html/hslibs/memo-library.html Hope this helps! --Tom Phoenix ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: Re: [Haskell-cafe] Slow IO
On 9/11/06, Daniel Fischer [EMAIL PROTECTED] wrote: The problem spec states that the input file contains about 500 test cases, each given by between 1 and 100,000 lines, each line containing a single word of between 2 and 1000 letters. So the file should be about 12.5G on average. I don't think that that necessarily follows. Although I've never seen the input file, of course, I imagine that many cases are fairly small, but designed to test the accuracy of your algorithm. A few are large (in one way or another) to test the extremes of your algorithm. But the overall size of the input file is probably much, much smaller than that estimate. (Maybe 1MB? Maybe 10MB?) A time limit of 7s is given. That's CPU time, and thus not including I/O, right? I couldn't find the answer on the SPOJ site. Their FAQ is a forum, but I don't see it there: http://www.spoj.pl/forum/viewforum.php?f=6sid=6c8fb9c3216c3abd1e720f8b4b5682b3 In any case, the problem can't be too large; the top twenty programs all finished in under 0.35 (CPU seconds?). Even if yours is a tenth as fast as the C and C++ programs, that would be 3.5s -- twice as fast as it needs to be. http://www.spoj.pl/ranks/WORDS1/ Of course, you don't have access to these other programs for comparison; but I hope that this gives you a better idea of the size (and manageability) of the task. Good luck with it! --Tom Phoenix ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] nondet function
On 9/9/06, Ashley Yakeley [EMAIL PROTECTED] wrote: Is it possible to write nondet? Yes; it (or something very similar) is discussed here: http://www.haskell.org/haskellwiki/Timing_out_computations Hope this helps! --Tom Phoenix ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How to round off frational number?
On 9/8/06, Sara Kenedy [EMAIL PROTECTED] wrote: I try to find some functions in Haskell library to deal with numeric such that the result in the following format (but I did not find) For example, 1/3 0.33 You're talking about a number-to-string conversion, right? You probably want showFFloat, from the Numeric module. There's also the Text.Printf module. Or you could write your own display code; but it's tricky to get it right for every possible case. http://haskell.org/ghc/docs/latest/html/libraries/base/Numeric.html#v%3AshowFFloat Hope this helps! --Tom Phoenix ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ReadP question
On 8/30/06, Chris Kuklewicz [EMAIL PROTECTED] wrote: -- Simulate (a?|b+|c*)*d regular expression But 'go' seems to not terminate with the leading 'star' Unless I'm missing something... The part of the pattern inside the parentheses should successfully match at least the empty string at the beginning of the string. Since it's regulated by the second (outer) 'star', it will keep matching as long as it keeps succeeding; since it keeps matching the empty string, it keeps matching forever in the same spot. To solve this problem, your implementation of 'star' could perhaps be changed to answer no more matches rather than infinitely many matches once the body fails to consume any characters. Hope this helps! --Tom Phoenix ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Why does Haskell have the if-then-else syntax?
I often find myself at odds with this choice. The reason is that I use Haskell as a host for embedded languages, and these often come with their own control flows. So I find myself wanting to write my own definition of the if-then-else construct that works on terms of some other type, e.g. tests on values of type Exp Bool instead of Bool, and at the same time make sure that the user doesn't use the built-in if-then-else. Sure, I can (and do) call my own version if_, ifElse or something else along those lines, but it's sure to be a constant source of programmer errors, writing if-then-else instead of if_ by habit. A thought that has crossed my mind on several occasions is, why not make the syntactic if-then-else construct rebindable, like the do notation? I think I know the answer already -- the do notation is syntactic sugar for = and company so it's easy to translate it into non-prelude-qualified versions of functions with those names. This is not the case for if-then-else. But it could be, the prelude could define a function if_ (or whatever) that the if-then-else construct is made to be sugar for, and thus also amenable to rebinding by not prelude-qualifying. Wouldn't this cause a conflict with specialized knowledge the compiler has about if-then-else, e.g. for optimizations? Tom -- Tom Schrijvers Department of Computer Science K.U. Leuven Celestijnenlaan 200A B-3001 Heverlee Belgium tel: +32 16 327544 e-mail: [EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Type-Level Naturals Like Prolog?
On Tue, 18 Jul 2006, Jared Warren wrote: % defining natural numbers natural(zero). natural(s(X)) :- natural(X). % translate to integers toInt(zero, 0). toInt(s(X), N) :- toInt(X, Y), N is Y + 1. Thank you. I can now more precisely state that what I'm trying to figure out is: what is 's', a predicate or a data structure? If it's a predicate, where are its instances? If not, what is the difference between the type language and Prolog such that the type language requires data structures? it's data structure, to be exact, it's data constructor - just like, for example, Just in Haskell. Haskell requires that all data constructors should be explicitly defined before they can be used. you can use Just to construct data values only if your program declares Just as data constructor with data definition like this: data Maybe a = Just a | Nothing Prolog is more liberate language and there you can use any data constructors without their explicit declarations, moreover, there is no such declarations anyway [deletia] i once said you about good paper on type-classes level programming. if you want, i can send you my unfinished article on this topic which shows correspondences between logic programming, type classes and GADTs So predicates and data constructors have similar syntax but different semantics in Prolog? That is right. The syntax and naming are different from Haskell though. They are called respectively predicate and function symbols/functors, and written like f(x1,...,xn) rather than F x1 ... xn. Terms are made of possibly nested function symbols and variables, e.g. f(f(f(a,X))) where f and a are used as function symbols Atoms are made of a predicate symbol and terms,e.g. p(f(f(f(a,X where p is used as a predicate symbol f and a are used as function symbols Note that the same name can be used with multiple argument numbers and both as a predicate and a function symbol. Say, for the sake of argument, if I wanted to do automatic translation, how would I tell which was which in a Prolog program? Based on the syntax. Basically the top-level symbols are predicate symbols and the nested ones are function symbols, e.g. in a clause p(f(X)) :- q(h(i)), j(k) = l(m). p, q and '=' are predicate symbols and all the rest are function symbols. It's probably good to read a bit about it in a proper reference. Wikipedia's Prolog entry lists a number of tutorials. Cheers, Tom -- Tom Schrijvers Department of Computer Science K.U. Leuven Celestijnenlaan 200A B-3001 Heverlee Belgium tel: +32 16 327544 e-mail: [EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: help with MPTC for type proofs?
David Roundy wrote: class Commutable a b d c commute :: Commutable a b d c = (Patch a b, Patch b c) - (Patch a d, Patch d c) But for this to work properly, I'd need to guarantee that 1. if (Commutable a b d c) then (Commutable a d b c) 2. for a given three types (a b c) there exists at most one type d such that (Commutable a b c d) The problem seems easily solvable, exactly as described. We need to take care of the two requirements separately. {-# OPTIONS -fglasgow-exts #-} {-# OPTIONS -fallow-undecidable-instances #-} module D1 where data Patch a b = Patch String deriving Show -- This is identical to what Tom Schrijvers wrote class Commutable a b c d | a b c - d, -- 2. a d c - b -- based on 1. + 2. -- But how do we make sure that Commutable a d c b exists whenever -- Commutable a b c d does? very easily: with the help of another -- type class instance (Commutable' a b c d, Commutable' a d c b) = Commutable a b c d I had not thought of using a double constraint. Very clever. Why not also put this constraint in the class declaration? You don't want any other instances of Commutable (or do you?): class (Commutable' a b c d, Commutable' a d c b) = Commutable a b c d | a b c - d, -- 2. a d c - b -- based on 1. + 2. Cheers, Tom -- Tom Schrijvers Department of Computer Science K.U. Leuven Celestijnenlaan 200A B-3001 Heverlee Belgium tel: +32 16 327544 e-mail: [EMAIL PROTECTED] Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] help with MPTC for type proofs?
On Thu, 25 May 2006, David Roundy wrote: Hi all, I've been thinking about extending some (experimental) GADT-based proof code that verifies that the darcs patch theory code is properly used. A given patch has type (Patch a b), and I'd like to be able to write something like commute :: (Patch a b, Patch b c) - (Patch a d, Patch d c) in such a way that the type system know that the type d is one particular type, uniquely determined by the types a, b and c. Currently, which I do is to make d be existential with data Pair a c where (:.) :: Patch a d - Patch d c - Pair a c commute :: Pair a c - Pair a c which prevents misuse of the returned pair, but doesn't allow proper use, for example we ought to be able to compile: test (a :. b) = do (b' :. a') - return $ commute (a :. b) (b'' :. a'') - return $ commute (a :. b) (a''' :. b''') - return $ commute (b' :. a'') return () but this will fail, because the compiler doesn't know that b' and b'' have the same type. So I'd like to write something like class Commutable a b d c commute :: Commutable a b d c = (Patch a b, Patch b c) - (Patch a d, Patch d c) But for this to work properly, I'd need to guarantee that 1. if (Commutable a b d c) then (Commutable a d b c) 2. for a given three types (a b c) there exists at most one type d such that (Commutable a b c d) I have a feeling that these may be enforceable using fundeps (or associated types?), but have pretty much no idea to approach this problem, or even if it's soluble. Keep in mind that all these types (a, b, c and d) will be phantom types. Hi David, I've quickly tried to a few alternatives in Hugs using FDs, but I've not been able to fully implement your requirement 1: 1) only FDs class Commutable a b c d | a b c - d, -- 2. a d c - b -- based on 1. + 2. but this does not enforce the existence of mirror instance Commutable a d c b. 2) FD + cyclic class hierarchy Alternatively, I wanted to write the following to capture 1.: class (Commutable a d c b) = -- 1. Commutable a b c d | a b c - d,-- 2. but this is not accepted by Hugs (or GHC) because their type inference algorithms would go into a loop: Class hierarchy for Commutable is not acyclic Perhaps some cycle detection techniques would allow type inference to deal with this sort of code? 3) FDs + Overlapping instances class CommutativePartners b d = Commutable a b c d | a b c - d -- b and d commute class Partners b d -- commutative closure of Partners class class CommutativePartners b d instance Partners b d = CommutativePartners b d instance Partners b d = CommutativePartners d b The last two instances are overlapping. GHC has a flag -fallow-overlapping-instances to allow this. This approach is not entirely safe if additional instances of CommutativePartners can be declared. Support for closed type classes is needed to prevent this. I'm not sure whether there is a way to fully realise requirement 1. AFAIK associated types are no more expressive than FDs. Cheers, Tom -- Tom Schrijvers Department of Computer Science K.U. Leuven Celestijnenlaan 200A B-3001 Heverlee Belgium tel: +32 16 327544 e-mail: [EMAIL PROTECTED] Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Code Review: Sudoku solver
On Thu, 6 Apr 2006, Claus Reinke wrote: Curry does not have a constraint solver of its own. It simply delegates all constraints to the FD solver of SICStus Prolog. or that of SWI Prolog (which prompted my attempt to install Curry). which was implemented by..hi, again!-) (*) The SWI-Prolog FD library is just a prototype implementation... looking for someone to replace it with a state-of-the-art implementation. The all_different constraint subsumes the rules that you describe, depending on the consistency algorithm used. FD solvers implement general but efficient algorithms that are much more complex than a few simple rules. I haven't yet been able to get Curry to work on my windows machine, but it seems to do a straightforward translation of these constraints to Prolog +FD solver, close to the one I've attached (an easy way to use external constraint solvers from Haskell;-). :) the docs you pointed to state that all_different, in declarative view, simply translates into mutual inequalities between the list members, and although I don't fully understand the sources, they seem to confirm that not much more is going on. The SWI-Prolog prototype library does nothing more than the declarative meaning, that's why it's a prototype. State-of-the-art all_different implementations are a lot more complicated (often based on graph algorithms) to do very strong propagation. Here is a paper about solving Sudoku with constraint (logic ) programming comparing a number of all_different algorithms and additional tricks: http://www.computational-logic.org/iccl/master/lectures/winter05/fcp/fcp/sudoku.pdf Cheers, Tom -- Tom Schrijvers Department of Computer Science K.U. Leuven Celestijnenlaan 200A B-3001 Heverlee Belgium tel: +32 16 327544 e-mail: [EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Code Review: Sudoku solver
since I haven't factored out the constraint propagation into a general module, the core of my code is a lot longer than the Curry version (about 60 additional lines, though I'm sure one could reduce that;-). the only negative point I can find about the Curry example is that it isn't obvious what tricks the FD-constraint solver is using Curry does not have a constraint solver of its own. It simply delegates all constraints to the FD solver of SICStus Prolog. The all_different constraint subsumes the rules that you describe, depending on the consistency algorithm used. FD solvers implement general but efficient algorithms that are much more complex than a few simple rules. See http://www.sics.se/sicstus/docs/latest/html/sicstus/Combinatorial-Constraints.html#Combinatorial%20Constraints for the SICStus FD all_different documentation. (ie., it would be nice to have a concise language for expressing propagation techniques, and then explicitly to apply a strategy to the declarative specification, instead of the implicit, fixed strategy of the built-in solver). CHR is meant as a highlevel language for expressing propagation. It (currently) does not include a strategy language though. Cheers, Tom -- Tom Schrijvers Department of Computer Science K.U. Leuven Celestijnenlaan 200A B-3001 Heverlee Belgium tel: +32 16 327544 e-mail: [EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: (!!) operator usage
Tom Davies tomdavies at exemail.com.au writes: [snip] Apologies for the complete misinformation! I don't know what I was thinking! Tom ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: (!!) operator usage
Neil Rutland neilrutland2 at hotmail.com writes: [snip] type Bob = [(Int, Int)] newLine :: Bob newLine = [(1,4)] i have tried to use the follwing but it returns the error below it. newLine !! 0 - (so that should give it the newLine list and try and return the 1st element of the list) the error reads thus ERROR file:.\VicotriaLine.txt:107 - Type error in final generator *** Term : newLine !! 0 *** Type : (Int,Int) *** Does not match : IO a newLine is already defined -- call it 'x' instead and !! will do what you expect. Tom ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Picking a shell for runCommand
It appears runCommand uses /bin/sh by default, but our environment needs tcsh. Is there any way to set an alternative shell? -Tom ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Cyclical Type Synonyms
I want to define a type for a function that returns its own type... type F a = a - (F a,a) But the compiler gives me an error: Cycle in type synonym declaration: Why is this a restriction? Of course I can create a user defined type, but then I need an extra mechanism to call the embedded function: data F a = F (a - (F a ,a)) call :: F a - a - (F a, a) call (F f) a = f a -Tom ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe