Hello dear community!
A really newbie question, but I can’t figure out why does this happen.
Reading the prelude docs , I’d expect that the abs
function would be imported in the REPL whenever I import Prelude
into it.
However, that’s not the case. Even more, greaterThan
isn’t aswell imported, but min
is (refering to Prelude’s Data.Ord). Whenever I try to use abs
I get an Unknown value
error. Ofc I can solve that by
Am I getting something wrong?
1 Like
Oh, nevermind, solved it.
Is just that I didn’t know how to read Pursuit docs
Should’ve seen this page to see what is actually imported from Prelude.
1 Like
Yeah it’s quite strange, but there’s its own reasoning.
For no more surprises I may try this cute little pattern:
# Project Prelude
If you ever find yourself thinking, "I wish `<ModuleName>` was in `Prelude`," or "I wish I didn't have to import `<ModuleName>` in each PureScript file," this design pattern is for you.
PureScript files can often have a lot of lines for just the import statements. While it makes it easier to see which function is being used in a given file, it can be tedious to import everything, even with tooling that enables auto-importing.
However, most projects and applications will define a project-specific Prelude to be used just in that project. Rather than typing something like this in each of your files:
```purescript
import Prelude
import Effect (Effect)
import Effect.Class (class MonadEffect, liftEffect)
import Effect.Aff (Aff, launchAff_)
import Effect.Aff.Class (class MonadAff, liftAff)
import Control.Monad.Reader.Class (class MonadReader, ask, local)
import Control.Monad.State.Class (class MonadState, get, put, modify_)
import Data.Array ((:), (!!))
import Data.Bifunctor (class Bifunctor, bimap, lmap, rmap)
import Data.Maybe (Maybe(..), maybe, fromJust)
import Data.Newtype (class Newtype, un)
This file has been truncated. show original
Hope that this helps some people
3 Likes
ajnsit
December 27, 2020, 1:20pm
#5
Since spacemacs’ Purescript support is so good, I tend to import everything explicitly. It also helps me remember the location of everything better.
In Spacemacs SPC-m-m-i-a
will import the symbol currently under the cursor for you.
2 Likes
Yes. This is only an issue outside of IDEs (e.g. REPL and Try PureScript ).
1 Like