[Haskell-cafe] Is it possible to declare assignment operators in Haskell?
Joe Quinn
headprogrammingczar at gmail.com
Wed Feb 5 21:52:31 UTC 2014
On 2/5/2014 7:37 AM, Alexander Alexeev wrote:
> Hello!
>
> I'm wondering, is there any way to declare assignment operators
> in Haskell? For example, strict assignment operators:
>
> x .= y -- equals: let x = y `deepseq` y
> x := y -- equals: x <- y `deepseq` y
>
> As far as I can tell, Template Haskell is not able to do anything like
> this, because I can't event quote expressions like `let x = y` or `x <-
> y`. Is there any other way (plugin for GHC, etc)? Or maybe I'm doing
> something wrong and TH is quite able to handle this task?
>
> I'm pretty sure that I could use a preprocessor, but I wonted to find
> a better solution.
>
There are things that "act like assignment", but quite differently than
what you are after, which looks like a macro of some sort.
For instance, one of the OpenGL packages defines (:=) = writeIORef, to
be used like
spoofel depth stencil = do
stencilVals <- map (> 0.35) <$> readIORef depth
stencil := stencilVals
What is the type of (.=) and (:=) that you desire? What is the larger
problem you are trying to solve?
More information about the Haskell-Cafe
mailing list