Re: [Haskell-cafe] Re: Polyvariadic functions operating with a monoid
Hello Kevin, 2010/10/9 Kevin Jardine kevinjard...@gmail.com: I was attempting to turn this into a small library and wanted to avoid exporting unwrap. I defined: polyToMonoid' = unwrap . polyToMonoid If you disable MonomorphismRestriction this definition typechecks just fine. Alternatively, you can ask ghci about the type of unwrap . polyToMonoid and paste that into the type sig. regards, Bartek Ćwikłowski ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Accepting and returning polyvariadic functions
Hello Will, 2010/8/11 Will Jones w...@sacharissa.co.uk: I'm trying to write a function (I'll call it `vtuple' for lack of a better name) that returns a function that itself returns multiple arguments in the form of a tuple. For example: vtuple f :: IO (Int - (Int, ())) vtuple g :: IO (Int - Int - (Int, (Int, ( If we drop the IO (as pointed out by Ryan Ingram), vtuple seems weird - the only sensible function of the type Int - Int - (Int, (Int, ())) is a function that collects its arguments and returns them in a tuple, so it doesn't touch the input function g at all, it only cares about g's arity. Here's the solution: vtuple f = eat (arity f) `mcomp` hListToTuple class HListToTuple l r | l - r where hListToTuple :: l - r instance HListToTuple HNil () where hListToTuple _ = () instance HListToTuple xs ys = HListToTuple (HCons x xs) (x,ys) where hListToTuple (HCons x xs) = (x,hListToTuple xs) Rest of the code (functions eat, arity and mcomp) is presented here: http://paczesiowa.blogspot.com/2010/03/generalized-zipwithn.html Regards, Bartek Ćwikłowski ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Hot-Swap with Haskell
Hello Andy, 2010/7/16 Andy Stewart lazycat.mana...@gmail.com: There are some problems with re-compile solution: 1) You can't save *all* state with some FFI code, such as gtk2hs, you can't save state of GTK+ widget. You will lost some state after re-launch new entry. For my 2008 GSOC application I wrote a demo app that used hot code reloading and it maintained gtk state just fine. The code (and video) is available at http://paczesiowa.dw.pl/ , it worked in ghc 6.8 and needed hs-plugins, so it won't work now, but the approach should work. regards, Bartek Ćwikłowski ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] polyvariadic function for Applicative instances
hello, Is it possible to have a function accept variable number of arguments, such that 'f' can be instantiated to different concrete types as f :: Applicative a = (e1 - f) - a e1 - A f f g a = pure g * a f :: Applicative a = (e1 - e2 - f) - a e1 - a e2 - A f f g a b = pure g * a * b f is just a left fold over the list of arguments. I've written about such things here: http://paczesiowa.blogspot.com/2010/03/generalized-zipwithn.html regards, Bartek Ćwikłowski ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Set Operations In Haskell's Type System
hello, 2010/5/6 John Creighton johns2...@gmail.com: a isa d if their exists a b and c such that the following conditions hold: a isa subset of b, b isa c c is a subset of d This definition doesn't make sense - it's recursive, but there's no base case, unless this is some kind of co-recursion. Are you sure that subset isn't what you really want? With subset you can already ask questions such as is tabby cat an animal?. If so, my code (from hpaste) already has this (iirc isDescendentOf ). regards, Bartek Ćwikłowski ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Set Operations In Haskell's Type System
hello, 2010/5/4 John Creighton johns2...@gmail.com: I will continue to try to solve the problem on my own but at the moment I'm able to get IsSuperSet to work but not the classes Isa, Child and IsSubSet to work. Unlike set theory IsSubSet is not the same as switching the order arguments in IsSuperSet because the searching is done in the opposite direction. In one case we are searching the parents and each child only has one parent. In the other Case we are searching the children and each parent could have multiple children). Since Subset is the opposite of Superset, you can search in the easier (up) direction, so it really is as easy as reversing the order of arguments. It's not possible to write class/type-level function Child a b | a - b, because functions (classes with fun-deps) must be deterministic. If you want to enumerate all children (based on Parent class instances), it's also impossible in this setup, it's probably possible with Oleg's second-order typeclass programming[1]. [1] http://okmij.org/ftp/Haskell/types.html#poly2 But what are you actually trying to achieve? I can't thing of anything useful that would require walking down the hierarchy tree (and backtracking) and it has to be done at the type level. Please use more descriptive type-variable names, type-level code should also be easy to read:) regards, Bartek Ćwikłowski ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe