[Haskell-cafe] Re: coherence when overlapping?

2006-04-12 Thread oleg
But I am still confused by the exact definition of coherence in the case of overlapping. Does the standard coherence theorem apply? If yes, how? If no, is there a theorem? Yes, the is, by Martin Sulzmann et al, the Theory of overloading (the journal version)

deriving Typeable

2006-04-04 Thread oleg
John Meacham wrote: things like DeepSeq and Typeable will most likely have optimized versions on various compilers which is why I'd like to see the restriction that the only way to create instances for these two classes is via the deriving mechanism of the compiler. Please make it so!

Re: FD improvement, variable quantification generalised propagation

2006-04-04 Thread oleg
Claus Reinke wrote: I hadn't given that much thought before, because FDs are meant to determine their range types, and there isn't much difference between universal and existential quantification if there is only one possible variable value, eg: (forall a in {Char}.

[Haskell-cafe] Defining instance needs allow-undecidable-instance?

2006-03-28 Thread oleg
Daniel McAllansmith wrote: When I try to add MonadError into the types I eventually hit the requirement for allow-undecidable-instances. Is there some way I can I avoid having to use this extension? class (Num i, Bounded i, Monad m, MonadError String m) = MonadSource i m | m - i

Re: [Haskell] Haskell as a markup language

2006-03-22 Thread oleg
shelarcy wrote: SXML can add useful function for macro, like this; (define (M:link keyword url) `(a (@ (href ,url)) ,keyword)) (define (M:link_amazon keyword asin) (M:link keyword `(http://www.amazon.co.jp/exec/obidos/ASIN/; ,asin /someone_id/))) (define (M:book keyword

Infix expressions

2006-03-14 Thread oleg
Doaitse Swierstra wrote: In Haskell we write `f` in order to infixify the identifier f. In ABC the stuff between backquotes is not limited to an identifier, but any expression may occur there. This would allow one to write e.g. xs `zipWith (+)` ys Chung-chieh Shan and Dylan Thurston

Suggestion: refine overlap handling for instance declarations

2006-03-14 Thread oleg
Claus Reinke wrote: overlapping instances with best-fit overlap resolution are useful because they give us an alternative way to write programs that we cannot write directly as long as current Haskell isn't expressive enough: (a) we can't specify that two types in an instance are not

[Haskell-cafe] Deepest functor [was: fmap for lists of lists of lists of ...]

2006-03-14 Thread oleg
Greg Buchholz wrote: Is it possible to make a typeclass like Functor, that has a function (say f_map), which would work for the infinite hierarchy of types: ([],[[]],[[[]]],...)? You do understand that this requires overlapping instances? Because the type [[Bool]] is still a list. In

[Haskell] Non-trivial transformations from the Haskell markup

2006-03-08 Thread oleg
Matijs Erisson, who suggested I provide rss.xml feed for my site. You can see the ChangeLog in the master format and its two renderings at http://pobox.com/~oleg/ftp/ChangeLog.hs http://pobox.com/~oleg/ftp/ChangeLog.html http://pobox.com/~oleg/ftp/rss.xml The updated archive

[Haskell] Haskell as a markup language

2006-03-01 Thread oleg
tags and their constraints), this message is not the complete code. The code is available from http://pobox.com/~oleg/ftp/Haskell/HSXML.tar.gz Please see the files HSXML.hs, HSXML_HTML.hs and the sample code sample1c.hs for the data-centric framework. The monad-centric framework is in one

[Haskell-cafe] (Un)termination of overloading resolution

2006-02-21 Thread oleg
Martin Sulzmann wrote: - The type functions are obviously terminating, e.g. type T [a] = [[a]] clearly terminates. - It's the devious interaction between instances/superclasss and type function which causes the type class program not to terminate. Is there a possible fix? Here's a

[Haskell-cafe] (Un)termination of overloading resolution

2006-02-21 Thread oleg
Let's consider the general case (which I didn't describe in my earlier email). In case we have an n-ary type function T (or (n+1)-ary type class constraint T) the conditions says for each type T t1 ... tn = t (or rule T t1 ... tn x == t) then rank(ti) rank(t) for each i=1,..,n I

[Haskell-cafe] (Un)termination of overloading resolution

2006-02-21 Thread oleg
Martin Sulzmann wrote: Let's consider the general case (which I didn't describe in my earlier email). In case we have an n-ary type function T (or (n+1)-ary type class constraint T) the conditions says for each type T t1 ... tn = t (or rule T t1 ... tn x == t) then rank(ti) rank(t)

[Haskell] Eliminating Multiple-Array Bound Checking through Non-dependent types

2006-02-10 Thread oleg
An earlier message showed an example of writing code with non-trivial static guarantees in the present-day Haskell (i.e., Haskell98 + rank-2 types). http://pobox.com/~oleg/ftp/Haskell/types.html#branding Although this approach obviously falls short of the genuine dependent typing, we

[Haskell] generic catch in a MonadIO

2006-02-07 Thread oleg
The ability to use functions 'catch', 'bracket', 'catchDyn', etc. in MonadIO other than IO itself has been a fairly frequently requested feature: http://www.haskell.org/pipermail/glasgow-haskell-users/2003-September/005660.html http://haskell.org/pipermail/libraries/2003-February/000774.html

[Haskell-cafe] Re: Fast Mutable Variables for the IO and ST monads

2006-02-07 Thread oleg
Simon Marlow wrote: I suggest you follow the same scheme as the unboxed array types, and have IOURef/STURef types, parameterised over the element type. Of course, we should have instances for all of the primitive numeric types plus Ptr, ForeignPtr, StablePtr, Bool. Perhaps it may be worth

[Haskell] Class-parameterized classes, and the type-level logarithm

2006-02-02 Thread oleg
We show invertible, terminating, 3-place addition, multiplication, and exponentiation relations on type-level Peano numerals, where _any_ two operands determine the third. We also show the invertible factorial relation. This gives us all common arithmetic operations on Peano numerals, including

[Haskell] Incoherent instances can make ST monad unsound

2006-01-26 Thread oleg
In the recent message about regions I wrote: Typeable constraint has reduced the problem of 'region nesting' to the regular problem of the 'linearity' of computations -- which is already solved in ST monad. We can add that pervasive 's' type parameter to our Q and IOM types. However, the

[Haskell] Re: IO Regions in Haskell98

2006-01-25 Thread oleg
testMinus1 = join $ runIOM $ withFile /etc/motd $ return . runIOM . qGetChar Isn't this the same situation we have in Haskell98 with respect to the regular IO? The safety of IO depends on the fact that the IO type constructor cannot be eliminated. Hence the

RE: [Haskell] IO Regions in Haskell98

2006-01-24 Thread oleg
Simon Peyton-Jones wrote: Don't side effects kill you? withFile foo (\q - writeIORef var q) No. Computations within the body of |withFile| must be within the |IOM| monad. These computations are built from |unit| and those computations exported from IORegions98 that are deemed safe.

[Haskell] IO Regions in Haskell98

2006-01-23 Thread oleg
After an experiment with the simple IO regions, one can conclude that the only implementation of the regions has to be complex. It seems however that there is a Haskell98 implementation of IO regions. The solution involves no higher-ranked types, and works both in GHC and Hugs. The idea is

Re: [Haskell] Simple IO Regions

2006-01-19 Thread oleg
Simon Peyton-Jones wrote: Previously I've thought of using a nested tuple type (m1, (m2, (m3 ( That was my thought too. But then we need the comparison operation on those 'm' (which are actually type eigen-variables). Not that it can't be done (it can, and several examples prove

[Haskell-cafe] Re: Type Eigenvariable

2006-01-19 Thread oleg
Bill Wood wrote: is |nabla x, nabla y. phi(x,y)| logically equivalent to |forall x, forall y. x y only-if phi(x,y)|? I use |P only-if Q| for |P materially implies Q| First of all, I should remark that Miller and Tiu introduce two calculi (with names that are hardly speakable, even in TeX).

[Haskell] Simple IO Regions

2006-01-17 Thread oleg
This message shows a very simple implementation of Monadic Regions (for the particular case of IO and reading the file). The technique *statically* guarantees that neither a file handle nor any computation involving the handle can leak outside of the region that created it. Therefore, the handle

[Haskell-cafe] Haskell DB bindings

2006-01-11 Thread oleg
Krasimir Angelov wrote: There are three active database libraries: HDBC, HSQL and Takusen. It is quite disappointing from my point of view. Recently there was the same situation with the GUI libraires. I think the dichotomy between lower-level Haskell libraries (whose API is closer/faithful

[Haskell-cafe] Haskell DB bindings

2006-01-10 Thread oleg
to the ``current list''. We are merely given the current element of the list. Perhaps the following links might be of help: http://www.eros-os.org/pipermail/e-lang/2004-March/009643.html http://pobox.com/~oleg/ftp/Haskell/misc.html#fold-stream http://pobox.com/~oleg/ftp/papers/LL3-collections

[Haskell] Re: ANN: HDBC (Haskell Database Connectivity)

2006-01-09 Thread oleg
Axel Simon wrote, in response to Keean Schupke dbConnectWith :: DbName - (DbHandle - IO Result) - Result dbConnectWith name workFn = do handle - dbConnectTo name workFn handle `finally` dbDisconnect handle In this way you avoid finalizers... and everthing is safe providing

[Haskell] Re: (small) records proposal for Haskell '06

2006-01-06 Thread oleg
Joel Reymont wrote: How does pattern matching work with HList? I would like to pass a HList to a function and only match if a certain field had a certain value. The code below defines the function foo that accepts a record and yields one value if the field PtX of the record has the value 0.

[Haskell] Re: (small) records proposal for Haskell '06

2006-01-05 Thread oleg
David Roundy wrote: The only solution I can imagine would be to implement a class for each field name. i.e. the only reasonble type of f I can imagine is something like f :: Integral i, RecordHasField_foo i r = r - r But that's a very complicated solution, and once one implemented that

[Haskell-cafe] ST monad

2006-01-03 Thread oleg
Bulat Ziganshin wrote: the following code can't go through typechecking import Control.Monad.ST import Data.Array.ST main = print $ runST $ do arr - newArray (1,10) 127 a - readArray arr 1 writeArray arr 1 216 b - readArray arr 1

[Haskell] Re: A question about fundeps - GADT interaction

2005-12-27 Thread oleg
Tomasz Zielonka wrote: I tried to implement another function: mapChildren :: (forall a. Term f a - Term f a) - Term f b - Term f b mapChildren fun t@(Lit x) = t mapChildren fun (IsZero t) = IsZero (fun t) mapChildren fun (Succ t) = Succ (fun t) mapChildren fun (If c t e) = If

[Haskell] Conditional typechecking with GADTs

2005-12-27 Thread oleg
Tomasz Zielonka wrote: The papers on GADTs have an example showing how you can transform, traverse and evaluate ASTs (or terms) with more type safety. I've used such an approach in one of my applications and it works remarkably well. However, I would like to be able to turn off that

[Haskell] Re: A question about fundeps - GADT interaction

2005-12-22 Thread oleg
[Sorry for possible duplication, our DNS server seems to be broken, and the sysadm is on vacation] I don't think that is the problem with GADTs. The following works untype :: Term f a - Term Untyped () untype (Lit x) = Lit x untype (Succ t) = Succ (untype t) untype (IsZero t) =

Re: [Haskell] Djinn and the inverse of a typechecker

2005-12-15 Thread oleg
The evaluator of the logic system is complete: if there is a solution, the evaluator will always find it in finite time. Is it also terminating? So if there is no solution it will tell you so. The evaluator used in the yesterday's message -- no. It is merely complete; if no solution

[Haskell-cafe] Re: Announcing Djinn, version 2004-12-11, a coding wizard

2005-12-14 Thread oleg
Stefan Monnier wrote: I expected at first you were doing some funky type class molestation so you can use djinn in your code and let Haskell fill it in. That has already been done: De-typechecker: converting from a type to a term http://www.haskell.org/pipermail/haskell/2005-March/015423.html

[Haskell-cafe] GADT question

2005-12-05 Thread oleg
John Meacham wrote: data Type = ForAll [TyVar] Rho -- Forall type | FunType Type -- Function type | TyCon TyCon -- Type constants | TyVar TyVar -- Always bound by a ForAll with the three synonyms and their constraints being

[Haskell] Re: Functional dependencies and type inference (2)

2005-12-04 Thread oleg
Stefan Monnier wrote: instance CpsForm t t where This can't be right, can it? In general no: the CPS of a function certainly doesn't fit the above pattern. So, if the source language has abstractions (the language in the original message didn't), we have to add another instance for CpsForm.

[Haskell] Re: Functional dependencies and type inference (2)

2005-11-30 Thread oleg
Louis-Julien Guillemette wrote: Say we are using a GADT to represent a simple language of boolean constants and conditionals, data Term a where B:: Bool - Term Bool Cnd :: Term Bool - Term t - Term t - Term t and we would like to perform a type-safe CPS conversion over this

[Haskell] GADT type inference problem

2005-11-30 Thread oleg
Let us consider the following simple code {-# OPTIONS -fglasgow-exts #-} module Foo where data Term a where B:: Bool - Term Bool C:: Term Bool - Term t - Term t I:: Int - Term Int shw (I t) = (I ++) . shows t shw (B t) = (B ++) . shows t shw (C p q) = (Cnd ++) .

[Haskell] Re: Type Class Question

2005-11-22 Thread oleg
Paul Govereau wrote: BTW, The above program is a translation of an idiomatic use of functors in ML (pardon my syntax): module A : sig type t = ... end module B : funsig(X:SHOW where t = A.t) sig bar : A.t - string end module C : SHOW where t = A.t open A open B(C) ML modules

RE: [Haskell] How to zip folds: A library of fold transformers

2005-10-29 Thread oleg
Hello! I'm sure you're aware of the close connection between your FR stuff (nice) and the foldr/build list-fusion work? I am now. Indeed, the 'FR' representation of lists is what one passes to 'build'. Incidentally, the higher-rank type of FR is a _requirement_ (otherwise, things won't type)

[Haskell] Re: Instances That Ignore Type Constraints? (HList-related)

2005-10-27 Thread oleg
Just to add one more example to Ralf's reply: We get exactly the same kind of problem if we try *Main null [fromEnum] interactive:1:6: Ambiguous type variable `a' in the constraint: `Enum a' arising from use of `fromEnum' at interactive:1:6-13 Probable fix: add a type

[Haskell-cafe] Typeclasses and GADT [Was: Regular Expressions without GADTs]

2005-10-19 Thread oleg
Ralf Hinze wrote: To me replacing a GADT by class and instance declarations seems the wrong way round. We should not forget that the DT in GADT stands for `data type'. Francois Pottier enumerated some problems with type inference of GADT code during his ICFP'05 invited talk. Various

Re: [Haskell-cafe] Regular Expressions without GADTs

2005-10-18 Thread oleg
Conor McBride wrote: Neither Oleg nor Bruno translated my code; they threw away my structurally recursive on-the-fly automaton and wrote combinator parsers instead. That's why there's no existential, etc. The suggestion that removing the GADT simplifies the code would be better substantiated

Re: [Haskell-cafe] Regular Expressions without GADTs

2005-10-18 Thread oleg
Conor McBride wrote: Neither Oleg nor Bruno translated my code; they threw away my structurally recursive on-the-fly automaton and wrote combinator parsers instead. That's why there's no existential, etc. The suggestion that removing the GADT simplifies the code would be better substantiated

[Haskell-cafe] Generic parser without GADTs

2005-10-16 Thread oleg
Also inspired by Ralf Hinze's post, I thought of removing GADTs from that code. The result is Haskell98! code, which works well in Hugs. The code seems to be a bit simpler too. Like the original code, the function 'parseAny' correctly discriminates between the list of characters (i.e., strings)

Re: [Haskell] How to zip folds: A library of fold transformers

2005-10-13 Thread oleg
/~oleg/ftp/Computation/Continuations.html#cdr-fstream especially the reference therein: Corrado Boehm and Alessandro Berarducci: Automatic Synthesis of Typed Lambda-Programs on Term Algebras ___ Haskell mailing list

[Haskell] Re: How to zip folds: A library of fold transformers

2005-10-12 Thread oleg
Correction: We show how to merge two folds into another fold `elementwise'. ... We need recursive types -- but again, never value recursion. There is no need for recursive types, actually. Higher-rank types are still present, which we need for fold anyway. Introducing recursive types wasn't a

[Haskell] How to zip folds: A library of fold transformers

2005-10-11 Thread oleg
We show how to merge two folds into another fold `elementwise'. Furthermore, we present a library of (potentially infinite) ``lists'' represented as folds (aka streams, aka success-failure-continuation--based generators). Whereas the standard Prelude functions such as |map| and |take| transform

[Haskell-cafe] A better, fair, and terminating backtracking monad [Was: Concurrency question]

2005-09-04 Thread oleg
, http://pobox.com/~oleg/ftp/Computation/monads.html#fair-bt-stream First of all, the monad can let succeed the computations that surely diverge in List and similar monads. As the code at the end of that file shows, the monad avoids depth-first traps, and can even handle left-recursion

[Haskell] How to use STArray?

2005-08-29 Thread oleg
Benjamin Franksen wrote: On Thursday 25 August 2005 19:58, Udo Stenzel wrote: [...] you'll need a type signature somewhere to help ghc resolve the overloading of newArray and readArray, which is surprisingly tricky due to the s that must not escape. This works: compute :: Int - Int

[Haskell-cafe] Control.Monad.Cont fun

2005-07-25 Thread oleg
On Thu, Jul 07, 2005 at 07:08:23PM +0200, Tomasz Zielonka wrote: Some time ago I wanted to return the escape continuation out of the callCC block, like this: getCC = callCC (\c - return c) It seems using shift/reset is better not only in principle but in practice as well. module Foo

Re: [Haskell-cafe] Re: Lists vs. Monads

2005-07-21 Thread oleg
Jonathan Cast wrote: ] You can't define most initial models without recursive (or ] inductive) data types in general, because initial models are defined ] inductively. ] You can't define head, tail, or foldr using the MonadPlus ] signature ] OK. Right. I forgot about the Church

[Haskell-cafe] Re: [Haskell] Re: A MonadPlusT with fair operations and pruning

2005-07-18 Thread oleg
Regarding the law of mif (aka ifte, aka soft-cut, aka logical conditional) mif (mif c t' e') t e = mif c (\x - mif (t' x) t e) (mif e' t e) You're right of course: mode matters for the predicates that involve negation, such as mif. However, I believe that the mode is orthogonal to the

[Haskell-cafe] Re: Lists vs. Monads

2005-07-17 Thread oleg
of that derivation is a note `How to take a TAIL of a functional stream' http://pobox.com/~oleg/ftp/Computation/Continuations.html#cdr-fstream The higher-rank type is needed only to express the polymorphic answertype. ___ Haskell-Cafe mailing list Haskell-Cafe

[Haskell] Re: A MonadPlusT with fair operations and pruning

2005-07-15 Thread oleg
on Jun 22 Andrew Bromage wrote about the usefulness of soft-cuts and don't care non-determinism in non-deterministic computations in Haskell. http://www.haskell.org/pipermail/haskell/2005-June/016037.html Thank you very much for your explanation, it was helpful indeed. You noted, Some of the

RE: [Haskell-cafe] Overlapping Instances with Functional Dependencies

2005-07-11 Thread oleg
Daniel Brown wrote: class Baz a b | a - b instance Baz (a - b) (a - [b]) instance Baz a a ...but Baz fails with this error... When confronted with overlapping instances, the compiler chooses the most specific one (if it is unique), e.g. `Baz (a - b) (a - [b])` is more specific

[Haskell-cafe] Re: Control.Monad.Cont fun

2005-07-07 Thread oleg
program). The CC monad transformer (derived from the CC library by Sabry, Dybvig, Peyton-Jones), freely available from http://pobox.com/~oleg/ftp/packages/LogicT.tar.gz is free from that drawback. BTW, with that monad transformer, the example looks as follows (again, in a de-sugared way

[Haskell] A MonadPlusT with fair operations and pruning

2005-06-21 Thread oleg
: success, failure -- but no cut continuation. Still, control logical operations are supported. The continuation-passing implementation was indeed difficult to find, although the result is deceptively simple. The code is freely available under the MIT license: http://pobox.com/~oleg/ftp/packages

[Haskell-cafe] Simulating OO programming with type classes; writing a factory fu nction

2005-06-01 Thread oleg
Alistair Bayley wrote: There's a small problem: how to write a factory function that returns values of various subtypes. The makeSubType function below won't compile, obviously because the returns types are different (they're not the same 'm'). Indeed, expressions in both branches of an `if'

[Haskell] Two-hole zippers and transactions of various isolation modes

2005-05-11 Thread oleg
In this part about zippers with two holes, we discuss the relationship between zippers and (database) transactions of various isolation modes. We show the updating enumerator and the corresponding zipper that maximally preserve sharing and can walk terms with directed loops. We demonstrate that a

[Haskell] Zipper as a delimited continuation

2005-04-27 Thread oleg
This is the first part of a reply to a query about a zipper with two foci, posted on this list by Oktaviandi Hadi Nugraha on Apr 13. In this part we introduce the framework to answer the question. Our treatment of zipper is quite different from that of Huet (JFP, 1997) and Hinze and Jeuring (JFP

[Haskell-cafe] Re: (Newbie) Dynamic Programming, Memoizing Etc.

2005-03-16 Thread oleg
Bryce Bockman wrote: How would you guys memoize the following code. simpleCalc :: (Int,Int) - (Int,Int) simpleCalc (1,l) = (1,l+1) simpleCalc (x,l) | (odd x) = simpleCalc (((3*x) + 1), 1 + l) | otherwise = simpleCalc ((x `div` 2), 1 + l) sCalc x = simpleCalc (x,0)

[Haskell-cafe] Re: Best practices for modular programming in Haskell

2005-03-16 Thread oleg
Benjamin Pierce wrote: For someone coming to Haskell from an OCaml background, one of the hardest things to get used to is the somewhat more bare bones module system that Haskell provides. ... This works fine as long as what you're exporting is just values, but it's awkward for types, since

[Haskell] De-typechecker: converting from a type to a term

2005-03-01 Thread oleg
This message presents polymorphic functions that derive a term for a given type -- for a class of fully polymorphic functions: proper and improper combinators. This is better understood on an example: rtest4 f g = rr (undefined::(b - c) - (a - b) - a - c) HNil f g *HC rtest4 (:[]) Just 'x'

[Haskell] Re: class assosiated types, via GADTs or FDs

2005-02-17 Thread oleg
in our case) http://pobox.com/~oleg/ftp/Haskell/types.html#partial-sigs But mainly, if we wish to hide some details of the representation, why not to use tools that are built for that, such as applicative functors? They are _easily_ implementable in Haskell, arguably idiomatic, and free from

[Haskell-cafe] Automatic pointless translation

2005-02-14 Thread oleg
This message is a literate Haskell98 code for translating proper linear combinators into a point-free style. That is, we will be converting (closed, albeit that is not strictly a requirement) terms of the form ``\x1 ... xn - term'' where each variable xi has at most one occurrence in term. The

[Haskell-cafe] Re: Point-free style (Was: Things to avoid)

2005-02-10 Thread oleg
contains the type signature to increase comprehension: prod:: (MCompose a b (c - d) e, MCompose f g (b,g) d) = (h - a) - (c - f) - h - e prod = (. ((. (,)) . mcomp)) . mcomp Here `prod' is indeed the categorical product. The second example is taken from http://pobox.com/~oleg/ftp

[Haskell] Re: Polymorphic types without type constructors?

2005-02-01 Thread oleg
I have been thinking about using Haskell (extended with higher ranked polymorphism) to demonstrate to my colleagues some ideas in second-order lambda calculus. It turned out, however, I am puzzled by the type system myself. So I've written to seek for help. :) I started with define Church

[Haskell] GADT and constraints [Was: Rebindable syntax for monads and arrows]

2005-01-10 Thread oleg
Simon Peyton-Jones wrote: |[ data MyVec a where |[ MkMyVec :: (Foo a) = a - MyVec a f x = case x of MkMyVec x - rhs constraints are always solved *lazily* when inferring, so we'd infer f :: Foo [a] = MyVec a - ... even without any overlap

[Haskell-cafe] Re: Typed Lambda-Expressions withOUT GADTs

2005-01-03 Thread oleg
(extensible) GADT. The complete new code is included. Where now? Well, counterexample fiends who want to provoke Oleg into inventing a new recipe had better write down a higher-order example. I just did, then deleted it. Discretion is the better part of valour. It is possible to undelete

[Haskell-cafe] Problem with fundeps.

2005-01-03 Thread oleg
On Sun, 2 Jan 2005 [EMAIL PROTECTED] wrote: I tried to generalize one of my old packages for quantum *abstract* computations, where state vectors are defined as functional objects, whose codomain has some arithmetic. It is easy to see that you can define (f + g) = \x - f x + g x etc. The

[Haskell-cafe] Re: Typed Lambda-Expressions withOUT GADTs

2005-01-01 Thread oleg
Ashley Yakeley wrote on the first day of 2005: This compiled with today's CVS GHC 6.3. I don't think you can do this without GADTs. It seems we can do without GADT -- roughly with the same syntax (actually, the syntax of expressions is identical -- types differ and we have to write

[Haskell-cafe] The difference between ($) and application

2004-12-13 Thread oleg
The operator ($) is often considered an application operator of a lower precedence. Modulo precedence, there seem to be no difference between ($) and `the white space', and so one can quickly get used to treat these operators as being semantically the same. However, they are not the same in all

Re: [Haskell-cafe] Equality of functions

2004-11-30 Thread oleg
Jules Bean wrote: From the point of view of a programmer, that's all there is to it: there is no way of proving two functions are the same except by exhaustively checking every input. That is too pessimistic, I'm afraid. There is also an intensional equality. Granted, it can be sound but

[Haskell-cafe] Re: Lexically scoped type variables

2004-11-26 Thread oleg
Simon Peyton-Jones wrote: In GHC at present, a separate type signature introduces no scoping. For example: f :: forall a. a - a f x = (x::a) would be rejected, because the type signature for 'f' does not make anything scope over the right-hand side, so (x::a) means

[Haskell] Typeful symbolic differentiation of compiled functions

2004-11-24 Thread oleg
Jacques Carette wrote on LtU on Wed, 11/24/2004 ] One quick (cryptic) example: the same difficulties in being able to ] express partial evaluation in a typed setting occurs in a CAS ] [computer algebra system]. Of course I mean to have a partial ] evaluator written in a language X for language

[Haskell] Re: A puzzle and an annoying feature

2004-11-24 Thread oleg
Andrew Bromage wrote: module FD where class C from to | from - to where g :: from - to h :: to - from instance C Char Bool where g c = c == 'T' h b = if b then 'T' else 'F' --f :: (C Char a) = Char - a f c = g c Indeed, functional dependencies are the way to

[Haskell] Closed Projections on HLists?

2004-11-17 Thread oleg
Jared Warren wrote: I'm doing some work with heterogeneous sets as provided by the HList library http://homepages.cwi.nl/~ralf/HList/. My code uses projections of sets internally and I keep running into the open-world assumption when I ask the type checker to infer the result of projections.

[Haskell] How to close a type class

2004-11-11 Thread oleg
It is well known that type classes in Haskell are open. A user may at any time extend a visible type class by providing a new instance. There are situations where such an extensibility is undesirable. We may want to prevent the user from adding an instance to our class for some specific type --

Re: [Haskell] Re: Global Variables and IO initializers

2004-11-04 Thread oleg
Jo'n Fairbairn wrote: The idea is simply that we should provide a mechanism of saying to a compiler this file (of data) is a module that exports only the variable v. ... So we tell the compilation system that file /somewhere/contains-v contains the value of the variable v::String, and that

[Haskell] Re: Global Variables and IO initializers

2004-11-04 Thread oleg
-archive.com/[EMAIL PROTECTED]/msg05186.html Incidently, some of that is already available in Haskell, http://pobox.com/~oleg/ftp/Haskell/types.html#partial-sigs ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell

Re: [Haskell-cafe] existential type problem

2004-10-22 Thread oleg
data Bar a m = forall t. (MonadTrans t, Monad (t m)) = Bar (t m a - m a) (t m Int) data Foo = Foo (forall a m. Monad m = Bar a m) Is it true that I cannot have a function foo run op = Foo (Bar run op) I guess the answer is yes and no. Let's consider the type of 'op':

Re: [Haskell-cafe] existential type problem

2004-10-15 Thread oleg
Andrew Pimlott wrote: I want values in my existential type to denote, for some monad, a monadic operation and a way to run the monad. Except, I want it mix the operation with operations in another monad, so it use a monad transformer. I'm afraid, that phrase was a little misleading. It

Re: [Haskell] GHC / Hugs Disagree on Constraints

2004-10-10 Thread oleg
Dominic Steinitz wrote: Did you get the first solution to work? When I tried it with hugs -98 I got Yes, in the process discovering some interesting behavior of Hugs. Here's the complete code that works with Hugs module Foo where class Bits a instance (Ord a, Bits a, Bounded a, Integral

Language extension idea (was Re: [Haskell-cafe] Re: OCaml list sees...)

2004-10-09 Thread oleg
Tom Pledger wrote: Something along these lines: class List l a | l - a where nil :: l cons :: a - l - l But that's not of much use, because there isn't a class method to recover the elements of a List. We could add more methods (corresponding to null, head, and tail)

[Haskell] Re: threading mutable state through callbacks

2004-10-07 Thread oleg
Jules Bean wrote: Unfortunately, it's not going to work. It's not going to work because some of the procedures take callbacks, and the callbacks are values of type IO (). I can see two solutions to this: a) revert to using an IORef, and use lexical scoping to define my callbacks in a

[Haskell-cafe] Re: How do I get a long iteration to run in constant space

2004-10-05 Thread oleg
I added two lines to your code: iterate2 f x n | seq f $ seq x $ seq n $ False = undefined iterate2 f x n = --- as before rk4Next f h (x, y) | seq f $ seq h $ seq x $ seq y $ False = undefined rk4Next f h (x, y) = -- as before I also increased ten times the number of steps for the last

[Haskell-cafe] Layered I/O

2004-09-15 Thread oleg
in the context of Scheme, is available here: http://pobox.com/~oleg/ftp/Scheme/io.txt More polished drafts exist, and even a prototype implementation. Unfortunately, once it became clear that the ideas are working out, the motivation fizzled. The discussion of i18n i/o highlighted the need for general

[Haskell] Applicative translucent functors in Haskell

2004-08-27 Thread oleg
ML is known for its sophisticated, higher-order module system, which is formalized in Dreyer-Crary-Harper language. A few months ago Ken Shan showed a complete translation of that language into System Fw: http://www.eecs.harvard.edu/~ccshan/xlate/ Ken Shan has concluded that languages

[Haskell] Re: Dependent Types in Haskell

2004-08-14 Thread oleg
Martin Sulzmann stated the goal of the append exercise as follows: ] Each list carries now some information about its length. ] The type annotation states that the sum of the output list ] is the sum of the two input lists. I'd like to give a Haskell implementation of such an append function,

[Haskell] Keyword arguments

2004-08-13 Thread oleg
We show the Haskell implementation of keyword arguments, which goes well beyond records (e.g., in permitting the re-use of labels). Keyword arguments indeed look just like regular, positional arguments. However, keyword arguments may appear in any order. Furthermore, one may associate defaults

RE: [Haskell-cafe] closed classes [was: Re: exceptions vs. Either]

2004-08-09 Thread oleg
Simon Peyton-Jones wrote: kind HNat = HZero | HSucc HNat class HNatC (a::HNat) instance HNatC HZero instance HNatC n = HNatC (HSucc n) There is no way to construct a value of type HZero, or (HSucc HZero); these are simply phantom types. ... A merit of

Re: [Haskell] Eliminating Array Bound Checking through Non-dependent types

2004-08-08 Thread oleg
Hello! Bjorn Lisper wrote: What is the relation to the sized types by Lars Pareto and John Hughes? It is orthogonal and complementary, as the message in response to Conor T. McBride indicated. What is the relation to classical range analyses for (e.g.) array index expressions, which have

Re: [Haskell] Eliminating Array Bound Checking through Non-dependent types

2004-08-06 Thread oleg
the link to the code: http://pobox.com/~oleg/ftp/Haskell/number-param-vector-code.tar.gz I should emphasize that all proper examples use genuine Haskell arrays rather than nested tuples. Yet the type of the array includes its size, conveniently expressed in decimal notation. One can specify

[Haskell-cafe] Partial signatures

2004-08-06 Thread oleg
Malcolm Wallace wrote: and since you cannot write a partial signature, Can't we really? It seems `partial signature' means one of two things: - we wish to add an extra constraint to the type of the function but we don't wish to explicitly write the type of the

[Haskell] Eliminating Array Bound Checking through Non-dependent types

2004-08-05 Thread oleg
There is a view that in order to gain static assurances such as an array index being always in range or tail being applied to a non-empty list, we must give up on something significant: on data structures such as arrays (to be replaced with nested tuples), on general recursion, on annotation-free

[Haskell] Re: type class does not compile

2004-07-12 Thread oleg
Ben Yu wrote: class Rule r u u' m where apply :: r - u - m u' data And = And data Bin a b o = Bin a b o instance (Monad m, Rule r1 u u' m, Rule r2 u' u'' m) = Rule (Bin r1 r2 And) u u'' m where apply (Bin r1 r2 _) u = apply r1 u = apply r2 Ghc complains about Could not

[Haskell-cafe] Re: Help in understanding a type error involving forall and class constraints

2004-07-06 Thread oleg
Is it possible to return an arbitrary unboxed array that was constructed in the ST monad (as an STUArray)? The issue is that you end up with a MArray class constraint that involves the state thread's 's' parameter, but this type variable gets

[Haskell] Exceptions in types and exception-free programming

2004-06-24 Thread oleg
S. Alexander Jacobson wrote: Also, is there a way to get the typesystem to tell you which functions may fail i.e. which functions have failMsg as an implicit parameter? Generally speaking, that is not that easy. If we have a functional composition (foo . bar), we wish its

<    1   2   3   4   5   6   >