On 11/04/2011, at 4:49 AM, Anwar Bari wrote:
> HI Cafe
> I have to make a function to check that I have one occurrence of the last
> element (z) of the same list [a,b] in the tuple
>
> [([a,b],z)]
> For example
> [([1,2],3),([1,1],5),([1,3],6)...] this is true because there is one
Anwar Bari schrieb:
> I have to make a function to check that I have one occurrence of the
> last
> element (z) of the same list [a,b] in the tuple
How about using Data.Map?
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.has
On Sun, 10 Apr 2011 18:49:59 +0200, Anwar Bari wrote:
HI Cafe
I have to make a function to check that I have one occurrence of
the last
element (z) of the same list [a,b] in the tuple
[([a,b],z)]
For example
[([1,2],3),([1,1],5),([1,3],6)...] this is true because there is
one s
On Sun, Apr 10, 2011 at 12:49 PM, Anwar Bari wrote:
> HI Cafe
> I have to make a function to check that I have one occurrence of the last
> element (z) of the same list [a,b] in the tuple
>
> [([a,b],z)]
> For example
> [([1,2],3),([1,1],5),([1,3],6)...] this is true because there is one
HI Cafe
I have to make a function to check that I have one occurrence of the last
element (z) of the same list [a,b] in the tuple
[([a,b],z)]
For example
[([1,2],3),([1,1],5),([1,3],6)...] this is true because there is one
single
z for each single list.
while this one is false
[
Oleg has just pointed out that the 'Show' constraint bellow does not
work if you try and use a function from the show class (say 'show'), as
the function:
test2 l = show l
has the type:
test2 :: forall a. (Show a) => a -> String
The technique below works to constrain for membership of a class, S
Frederik Eaton writes:
> > You need to swap the arguments to TCons...
> >
> > data TCons l a = TCons !l a
> >
> > Then:
> >
> > instance Functor (TCons (TCons HNil a)) where
> >fmap f (TCons (TCons HNil x) y) = TCons (TCons HNil (f x)) y)
>
> How does one solve this problem in general, i.e
> You need to swap the arguments to TCons...
>
> data TCons l a = TCons !l a
>
> Then:
>
> instance Functor (TCons (TCons HNil a)) where
>fmap f (TCons (TCons HNil x) y) = TCons (TCons HNil (f x)) y)
How does one solve this problem in general, i.e. when the arguments to
a type are in the wr
David Menendez wrote:
instance Functor ((,) a) where
fmap f (x,y) = (x, f y)
If we get rid of '(,)' and redefine '(a,b)' as sugar for 'TCons a (TCons
b HNil)' (or whatever), then there is no way to declare the above instance. I don't think that's a deal-kil
Frederik Eaton writes:
> > One way t make tuples into sugar for HLists would be to effectively
> > have a series of declarations like these:
> >
> > type (a,b) = TCons a (TCons b HNil)
> > type (a,b,c) = TCons a (TCons b (TCons c HNil))
> >
> > But then we can't use tuples in instance
Frederik Eaton wrote:
That's a neat technique. Since it's so general it would be nice if
there were a way to make it more automatic, could one use template
haskell? It seems one should be able to write
HListConstraint $(mkConstraint Show) l
to generate the declarations automatically.
Frederik
Th
That's a neat technique. Since it's so general it would be nice if
there were a way to make it more automatic, could one use template
haskell? It seems one should be able to write
HListConstraint $(mkConstraint Show) l
to generate the declarations automatically.
Frederik
On Sun, Mar 20, 2005 at
Frederik Eaton wrote:
Another thing which I don't think is mentioned in the paper, which is
convenient, is that you can define HLists all of whose elements are
members of a given class:
class HListShow l
instance HListShow HNil
instance (Show a, HListShow l) => HListShow (a :* l)
You can avoid t
> > This was brought up in passing in a recent conversation on
> > haskell-cafe
Sorry, mairix was malfunctioning...
> > It certainly seems like an interesting idea, Would type inference
> > still work okay?
I don't understand all of the issues. One is that in the HList paper,
rather than constru
John Meacham writes:
> This was brought up in passing in a recent conversation on
> haskell-cafe
>
> http://www.haskell.org//pipermail/haskell-cafe/2005-March/009321.html
>
> It certainly seems like an interesting idea, Would type inference
> still work okay?
>
> The other problem mentioned is
This was brought up in passing in a recent conversation on haskell-cafe
http://www.haskell.org//pipermail/haskell-cafe/2005-March/009321.html
It certainly seems like an interesting idea, Would type inference still
work okay?
The other problem mentioned is that they are not quite isomorphic, sin
HList seems just like a tuple, but more powerful because one can
access the type structure directly, and more cumbersome because one
has to use lengthier constructors a 'nil' terminator. So why not just
make tuples synonyms for HLists, so one can use HLists with the
shorter notation, and have the a
17 matches
Mail list logo