tomjaguarpaw / haskell-opaleye

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is there a cast operator?

abigailalice opened this issue · comments

I'm trying to round a float to an integer, and don't see anything the Opaleye.Operators module. I was able to create a round function, but get a type error when I try to use it, and rewriting the command in postgresql explicitly made it look like I still need a cast to avoid the type error.

I assume CastSqlExpr or castToType are supposed to implement this functionality internally, but looking at them I don't see how to actually use them to implement a cast operator correctly myself.

How about:

https://hackage.haskell.org/package/opaleye-0.9.2.0/docs/Opaleye-Column.html#v:unsafeCast

(I should move this operator into Opaleye.Field but until then please use it from Opaleye.Column or from the top level, Opaleye.)

I was just looking under c in the index, but that it looks like it, thank you.

OK, let me know if I can be of any more help.

That seemed to fix the issue, thanks.