Simple and point in winghci

Why does it work ...

Just.(+3) $ 6.7
Just $ truncate 8.9

... but not that?

Just.truncate $ 8.9

I tried to enable truncate for a simple Double -> Int:

let f :: Double -> Int; f = (\ x -> truncate x);

... But it's not a problem...

Just.f $ 5.6

<interactive>:41:1:
Failed to load interface for `Just'
Use -v to see a list of the files searched for.

Many thanks!

+3
source share
2 answers

When you want to compose functions, it's better to write f . gthan f.g. This is a little more readable, and you avoid issues like this.

If you have something like Foo.baror Foo.barin Haskell, it is parsed as a qualified name. Therefore, it Just.fdoes not work: Justit is not a module, therefore the “interface” for Justcannot be loaded.

Just.(+3) : (+3) - , , . - , . (.), Just . (+3).

+10

(, Data.Map.insert), , Just. , .

+4

All Articles