On 11/2/06, Yitzchak Gale [EMAIL PROTECTED] wrote:
GHC says:
Functional dependencies conflict between instance declarations:
instance Replace Zero a a (a - a - a)
instance (...) = Replace (Succ n) a [l] f'
Not true. The type constraints on the second instance
prevent any
On Tue, Oct 31, 2006 I wrote:
Consider the following sequence of functions
that replace a single element in an n-dimensional
list:
replace0 :: a - a - a
replace1 :: Int - a - [a] - [a]
replace2 :: Int - Int - a - [[a]] - [[a]]
Generalize this using type classes.
Thanks to everyone for the
Consider the following sequence of functions
that replace a single element in an n-dimensional
list:
replace0 :: a - a - a
replace0 = const
replace1 :: Int - a - [a] - [a]
replace1 i0 x xs
| null t= h
| otherwise = h ++ (replace0 x (head t) : tail t)
where (h, t) = splitAt i0 xs
replace2
On Tue, Oct 31, 2006 at 11:02:03AM +0200, Yitzchak Gale wrote:
Consider the following sequence of functions
that replace a single element in an n-dimensional
list:
replace0 :: a - a - a
replace1 :: Int - a - [a] - [a]
replace2 :: Int - Int - a - [[a]] - [[a]]
Generalize this using type
Tomasz Zielonka wrote:
It's quite easy if you allow the indices to be put in a
single compound value.
Hmm. Well, I guess I don't need to insist on the exact
type that I gave in the statement of the puzzle - although
something like that would be the nicest.
This is actually a function that is
Yitzchak Gale wrote:
Tomasz Zielonka wrote:
If you insist that each index should be given as a separate
function argument, it may be possible to achieve it using the tricks
that allow to write the variadic composition operator.
I am not familiar with that. Do you have a reference?
Is that
See
Connor McBride's Faking It: Simulating Dependent Types in Haskell
http://citeseer.ist.psu.edu/mcbride01faking.html
It might help; your example makes me think of the nthFirst function.
If it's different, I'md wager the polyvariadic stuff and nthFirst can
be reconciled on some level.
Nick
Rearranging...
Nicolas Frisby wrote:
On 10/31/06, Greg Buchholz [EMAIL PROTECTED] wrote:
...That first article is the strangest. I couldn't reconcile the fact
that if our type signature specifies two arguments, we can pattern
match on three arguments in the function definition.
Greg Buchholz wrote:
...That first article is the strangest. I couldn't reconcile the fact
that if our type signature specifies two arguments, we can pattern
match on three arguments in the function definition. Compare the number
of arguments in the first and second instances...
class
Does that explain how, why, or when you can use more arguments than
you are allowed to use? Or is it just another example of using more
arguments than you are allowed to use? Is this a Haskell 98 thing, or
is it related to MPTCs, or fun deps, or something else?
I don't understand you can
On Tue, Oct 31, 2006 at 03:12:53PM +0200, Yitzchak Gale wrote:
But I would rather not be forced to write things like
replace (I 0 $ I 2 $ I 3 $ ())
in my code. My first attempt was very similar to yours,
except I used
replace (0, (2, (3, (
instead of your Index type.
I started
Arie Peterson wrote:
] I'm not sure I'm getting your point, but this is just because in the
] second instance, the second parameter of BuildList is 'a - r', so the
] specific type of 'build\'' is '[a] - a - (a - r)' which is just '[a] -
] a - a - r' (currying at work).
I guess it just looks
Greg Buchholz wrote:
I guess it just looks really strange to my eyes. For example, foo
and bar are legal, but baz isn't. That's what I was thinking of the
situation, but I guess the type classes iron out the differences.
foo :: Int - Int - Int - Int
foo 0 = (+)
bar :: Int - Int - Int
13 matches
Mail list logo