Re: [Haskell-cafe] distinguish functions from non-functions in a class/instances

2007-12-07 Thread Philipp N.
oleg-7 wrote: > > > In fact, that distinction is possible. The following article > > How to write an instance for not-a-function > http://okmij.org/ftp/Haskell/typecast.html#is-function-type > > specifically describes a method of writing an instance which is > selected only when t

Re: [Haskell-cafe] distinguish functions from non-functions in a class/instances

2007-12-06 Thread Philipp N.
Ryan Ingram wrote: > > No, that doesn't work; it's close, but not quite. liftM doesn't have the > right type signature. > > liftM :: Monad m => (a -> r) -> (m a1 -> m r) > > What would work is if you could define a function > liftLast :: Monad m => (a0 -> a1 -> ... -> aN -> r) -> (a0 -> a1 -

Re: [Haskell-cafe] distinguish functions from non-functions in a class/instances

2007-12-05 Thread Ryan Ingram
No, that doesn't work; it's close, but not quite. liftM doesn't have the right type signature. liftM :: Monad m => (a -> r) -> (m a1 -> m r) What would work is if you could define a function liftLast :: Monad m => (a0 -> a1 -> ... -> aN -> r) -> (a0 -> a1 -> ... -> aN -> m r) then nary' f = ru

Re: [Haskell-cafe] distinguish functions from non-functions in a class/instances

2007-12-05 Thread Dan Weston
Wouldn't any isomorphism do (like the Identity monad)? How about nary' f = runIdentity . nary (liftM f) . return Brandon S. Allbery KF8NH wrote: On Dec 5, 2007, at 16:00 , Philipp N. wrote: the odd thing is. you can get this to work, if you have a terminating type as result type (for examp

Re: [Haskell-cafe] distinguish functions from non-functions in a class/instances

2007-12-05 Thread Brandon S. Allbery KF8NH
On Dec 5, 2007, at 16:00 , Philipp N. wrote: the odd thing is. you can get this to work, if you have a terminating type as result type (for example (IO x)). then you can work with all types (IO x), (a -> IO x), (a -> b -> IO x), ... but i don't want this delimiter IO! any ideas? Use ST i

[Haskell-cafe] distinguish functions from non-functions in a class/instances

2007-12-05 Thread Philipp N.
Hello, i'm trying to wrap functions (a -> b -> ... -> z) of any arity to functions of type ([String] -> y), where list of strings replaces the typed arguments. one attempt looks like this (here written with type families, you can replace it by functional dependencies or what ever): type family