This is a question about the use of type classes in Haskell.
I get an error (below) when trying to compile the code (below and at
https://github.com/chrisdew/haskell-sandbox/blob/master/not_working_but_clean.hs
).
As someone just learning Haskell, I have tried following GHC's advice,
but I think
On 14/04/11 13:00, Chris Dew wrote:
class Stream a b c d where
(-) :: a - (b - c) - d
instance Stream (IO d) d (IO c) (IO c) where
f - g = f= g
instance Stream d d (IO c) (IO c) where
f - g = g f
instance Stream d d c c where
x - y = y $ x
I notice that in all
Hi Chris
What does the Stream class *do* though?
class Stream a b c d where
(-) :: a - (b - c) - d
Even with Neil's change its still quite unusual:
class Stream a b c where
(-) :: a - (b - c) - c
In the first formulation there is an input of type a, a function (b -
c) and a result of
@Neil Brown - That did it. It's not the ideal solution, as all -
are 'coerced' into being 'IO x' (if the rightmost term is an 'IO x'.
But it'll do for the time being.
Many thanks,
Chris.
On 14 April 2011 13:50, Neil Brown nc...@kent.ac.uk wrote:
On 14/04/11 13:00, Chris Dew wrote:
class
@Stephen Tetley - The stream class exists simply to allow for the
creation of a - operator which can be used to 'Stream' data through
multiple pure and IO functions, on the way to some form of output.
It's probably not a great idea, as there are more idiomatic solutions
in Haskell - I'm sure
On 14 April 2011 20:35, Chris Dew cms...@gmail.com wrote:
Could you suggest how these constraints could be expressed in the
Haskell type system?
Hi Chris
I'm afriad I'd have to decline - generally in Haskell implicit
lifters are problematic, so it isn't something I'd be looking to
solve.
Thanks, that link's very relevant to what I'm trying. For the time
being I'll accept a partial solution where the last two types are now
the same, and try to improve it when my knowledge of Haskell improves.
I really want (hello - bracket) in (hello - bracket -
putStrLn) to have a type of