I can't use fromInteger or realtoFrac in curry - curry

I'm using an old version of curry and all functions of Haskell works fine so far, but I have problem with realtoFrac and fromInteger
Prelude> :t fromInteger
PAKCS_Main_Exp.curry, line 2.17: Error:
`fromInteger' is undefined
ERROR occurred during parsing!
Prelude> :t realtoFrac
PAKCS_Main_Exp.curry, line 2.17: Error:
`realtoFrac' is undefined
ERROR occurred during parsing!
I think that this can happen because is an old version, so, in old versions of curry how can I use realtoFrac or fromInteger?
Thanks in advance and apologies for my bad English

It depends on which compiler and version you are using. So here is an answer for most of them.
PAKCS 1.x and most old versions of KICS2 did not support type classes.
There, a replacement for fromInteger you might be interested in should be in the module Float as i2f.
For newer versions of PAKCS since 2.0, fromInteger available in the Prelude.
Since there is only one type for floating point and none for fractions of Integers, realToFrac does not exist.
The function realToFrac is available in the Prelude since version 3.0 of the standard library, which is included in the newest compiler versions.

Related

Cannot import value abs from module Data.Number

The abs method of the purescript-numbers package is documented here:
https://pursuit.purescript.org/packages/purescript-numbers/9.0.0/docs/Data.Number#v:abs
However, consider this simple code example which implements this method:
import Data.Number (abs, toNumber, isFinite, sqrt)
j :: Number
j = abs -32.5
This produces the following error:
Cannot import value abs from module Data.Number
It either does not exist or the module does not export it.
Is this a bug, or intended behavior?
What is the correct way to import / use the abs method of the Data.Number library?
My suspicion is that you're probably using PureScript compiler v0.14.x and a corresponding package set 0.14.x, but at the same time are looking at the latest versions of the libraries on Pursuit.
Just about a week ago, the new version of PureScript compiler 0.15.0 came out, and with it came many breaking changes (most notably, ES-format foreign modules), and as is tradition in such cases, the community took the opportunity to do some refactoring while we're at it.
One instance of such refactoring was moving the abs function (as well as many other functions) from the Math module (in the math library) to the Data.Number module (in the numbers library).
This means that if you're using PureScript 0.15 and higher, abs is in Data.Number, but if your version of PureScript is lower, the function is in the Math module.

type mismatch errors when upgrading from scala 2.9 to 2.13.2

I recently revived an old library that was written in scala 2.9, and I created a new scala project using scala 2.13.2
I am getting errors like the following:
type mismatch;
found : scala.collection.mutable.Buffer[Any]
[error] required: Seq[Any]
Was there a specific change between 2.9 to 2.13.2 that involved not implicitly casting sequences or something that might solve many of these types of compile errors?
I had to add .toSeq to many of my function return statements that were vals of Buffer[Any] that needed to be passed as an arguement to a function expected a Sequence.
Quite a lot things happened in the last 7+ years (including rewrite of the collections library).
If adding .toSeq solves your problem - just go for it.
If you want to know what exactly has changed - try upgrading version-by version: first upgrade to scala-2.10., then to 2.11., then 2.12.*, then, finally, to 2.13.2.
At each upgrade you'll probably see deprecation warnings. Fix them before upgrading to the next version.
Brave, but perhaps bad form, to disturb the dead. Nevertheless, maybe pass mutable.Buffer as mutable.Seq instead of Seq which is by default immutable.Seq. Consider
val mb = mutable.Buffer(11, Some(42))
val ms: mutable.Seq[Any] = mb // OK
val is: Seq[Any] = mb // NOK

Prevent type mismatch error indications in Intellij IDEA?

In Intellij IDEA, I have a Scala case class expecting Longs as arguments. The arguments passed in are numbers, which intellij interprets as Ints and reports an error on it. The code compiles without errors or warnings, so he compiler (and I) don't care. It's pretty easy to fix by putting a l after the number, but that is cumbersome and does not increase readability. Is there a setting somewhere in Intellij Idea to fix this behavior?
There is an open bug (see also the linked issues):
SCL-7729 Highlight error with implicit conversion of covariant type

Int extension not applied to raw negative values

My extensions to the Int type do not work for raw, negative values. I can work around it but the failure seems to be a type inference problem. Why is this not working as expected?
I first encountered this within the application development environment but I have recreated a simple form of it here on the Playground. I am using the latest version of Xcode; Version 6.2 (6C107a).
That's because - is interpreted as the minus operator applied to the integer 2, and not as part of the -2 numeric literal.
To prove that, just try this:
-(1.foo())
which generates the same error
Could not find member 'foo'
The message is probably misleading, because the error is about trying to apply the minus operator to the return value of the foo method.
I don't know if that is an intentional behavior or not, but it's how it works :)
This is likely a compiler bug (report on radar if you like). Use brackets:
println((-2).foo())

type not inferred correclty in intellij

I am using slick's for expression, and seeing some strangeness in terms of intellij's inferred type. Here are the unexpected result:
Why in the second case, it is not Query[Int, Int] but instead becomes Query[Nothing, Nothing]. I seem to lose some type information.
What's to say? IDEA has it's own parser and typer and it is not that hard to confuse it. If you care about fidelity between your IDE and the Scala compiler, the Scala IDE (which runs in Eclipse) would be better for you.
Personally, I dislike Eclipse more than I do the vagaries of the IDEA Scala plug-in.