purescript / documentation Goto Github PK
View Code? Open in Web Editor NEWDocumentation for the PureScript language, compiler, and tools.
License: Other
Documentation for the PureScript language, compiler, and tools.
License: Other
Run:
npm install -g purescript pulp bower
pulp init
bower install purescript-outwatch
npm install rxjs snabbdom
Edit src/Main.purs
:
module Main where
import OutWatch
main = render "#app" (h1 [text "Hello World"])
Create index.html
:
<body>
<div id="app"></div>
<script type="text/javascript" src="index.js"></script>
</body>
Run:
pulp --watch browserify --to index.js
Output:
Error 1 of 3:
in module RxJS.Observable
at bower_components/purescript-rxps/src/RxJS/Observable.purs line 117, column 1 - line 117, column 52
Module Test.QuickCheck was not found.
Make sure the source file exists, and that it has been provided as an input to psc.
See https://github.com/purescript/documentation/blob/master/errors/ModuleNotFound.md for more information,
or to contribute content related to this error.
Error 2 of 3:
in module RxJS.Observable
at bower_components/purescript-rxps/src/RxJS/Observable.purs line 118, column 1 - line 118, column 37
Module Test.QuickCheck.Gen was not found.
Make sure the source file exists, and that it has been provided as an input to psc.
See https://github.com/purescript/documentation/blob/master/errors/ModuleNotFound.md for more information,
or to contribute content related to this error.
Error 3 of 3:
in module Main
at src/Main.purs line 3, column 1 - line 3, column 16
Module OutWatch was not found.
Make sure the source file exists, and that it has been provided as an input to psc.
See https://github.com/purescript/documentation/blob/master/errors/ModuleNotFound.md for more information,
or to contribute content related to this error.
* ERROR: Subcommand terminated with exit code 1
For more details about using Eff, how it works, and how to define your own side effects, see this post.
35778 verbose stack Error: [email protected] postinstall: node lib/install.js
35778 verbose stack Exit status 1
35778 verbose stack at EventEmitter. (/Users/alcaljos/.nvm/versions/node/v7.10.1/lib/node_modules/npm/lib/utils/lifecycle.js:279:16)
35778 verbose stack at emitTwo (events.js:106:13)
35778 verbose stack at EventEmitter.emit (events.js:194:7)
35778 verbose stack at ChildProcess. (/Users/alcaljos/.nvm/versions/node/v7.10.1/lib/node_modules/npm/lib/utils/spawn.js:40:14)
35778 verbose stack at emitTwo (events.js:106:13)
35778 verbose stack at ChildProcess.emit (events.js:194:7)
35778 verbose stack at maybeClose (internal/child_process.js:899:16)
35778 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
35779 verbose pkgid [email protected]
It would be nice to add page titles if possible. I'm not sure if this is a quick fix by modifying the existing script or not, but we can close this if it's a hassle now.
Not to be confused with the style guide we have for library maintainers.
(ref from purescript/purescript#2819) If it has been fixed then what is the entry point for installing PS on Linux (Ubuntu or Mint etc) ? My searches for guides to install have yielded misleading and contradicting directions. Why do the instructions on the web-page you mention force you into nodejs etc. What OS was your beginner using? I can try using the same as I have plenty of spare hardware here. I managed to compile some simple very crude .psc files into js which is a good start. I built the compiler from scratch - at least then I can see some of the structure and see where is puts the executable. I guess that I am doing it hard but now that I have found that it compiles at least some .psc code I am quite excited to continue. The code that I compiled was done on geany (very quick, flexible and handy) but I could not include any imports. I guess pulp etc would setup an environment for me...
The FFI:
invoking pulp run
in the Getting Started guide throws a warning No type declaration was provided for the top-level declaration of main....
This would cover questions such as
Functor Tuple
instancefoldJson
from argonaut does just by looking at the type signatureIf anyone has any other suggestions for things which would be useful to cover, please comment and let me know.
There isn't a single place in which all the _
forms are documented, but there is docs for some specific syntaxes:
But I know it can also be done in case..of
expressions, also, but that's not currently documented. Are there other places this can be used?
Should we document this as "Partial application of (special) syntactic expressions"?
Some type classes provide default implementations as functions (since default members are not supported yet). However, to use those, one needs eta-expand them, or the compiler will yell that the instance does not exist yet.
I'm not sure how this restriction comes up, but it would be nice to document this.
I think it might fit in the Haskell differences
part, in the section about the lack of default members.
https://github.com/purescript/documentation/blob/master/guides/PureScript-Without-Node.md
Not sure how others feel about this, but to me it simplifies Node-free development.
Things that people wanted documenting:
Newtype
-- Difference between keyword and type class.
-- Removed runAdditive
in v0.10, moved to wrap
from Newtype
class. Why have run*
in first place?
Functional Dependencies
-- What type-checking errors does it resolve?
-- When should I use functional dependency in my type class?
Typed-holes and type wildcards
-- Names are similar, needs clarification.
Compile Iteration Techniques
-- Hole-driven development with typed-holes.
-- Faculties of editor plugins. Using pscid as editor-independent alternative.
-- Iterating module while testing in psci.
Generics
-- How to use generics to encodeJson
from argonaut?
-- Old generics (purescript-generics) vs new generics (purescript-generics-rep, enabled by fun-deps)
It fails by hanging after saying purs isn't working:
$ npm install -g purescript
/home/wink/.npm-global/bin/purs -> /home/wink/.npm-global/lib/node_modules/purescript/bin/purs.js
> [email protected] postinstall /home/wink/.npm-global/lib/node_modules/purescript
> node lib/install.js
⚠ The `/home/wink/.npm-global/lib/node_modules/purescript/vendor/purs` binary doesn't seem to work correctly
⚠ pre-build test failed
ℹ compiling from source
The problem is Arch uses ncurses6 where as PS is using ncurses5. I was able to build PS from sources and that worked, but then when I tried to use pulp init
it failed saying it couldn't find libtinfo.so.5. The solution ncurses 5 was to install ncurses5-compat-libs after doing so now pulp init
worked with my purs
compiled from sources.
I then guessed that maybe the reason the npm install -g purescript
failed was because I was missing ncurses5. So I removed purs
from my $PATH and reran npm install -g purescript
and it worked!
So I'd like to suggest the npm instructions in website and Getting Started page be updated to reflect this information. I can take a stab at updating Getting-Started.md if you'd like.
I cannot import Data.List or Data.Foldable. Neither of them even show up on the list of modules that I can possibly import.
I followed the Getting Started guide exactly up to that point.
Some information in the Values page should be in the Syntax page. See #16 (comment)
Some PS functions are optimized away, like (<<<)
and ($)
. We should add a docpage which introduces the optimizer and some important things to know it does, as a PureScript user.
I've avoided using ($)
because I thought it added another layer to the stack for each use, but I'll use it more after learning that PSC optimizes it away.
I hope that this is the right place: while doing the exercises for the book I got some warnings where the link destination does not exist. https://github.com/purescript/purescript/blob/master/src/Language/PureScript/Errors.hs#L154 does point to UnusedImport.md
here but the document is missing from this repo which is why I opened this issue here.
Warning 4 of 4:
in module Data.AddressBook
at src/Data/AddressBook.purs line 7, column 1 - line 7, column 26
The import of module Data.Maybe is redundant
See https://github.com/purescript/documentation/blob/master/errors/UnusedImport.md for more information,
or to contribute content related to this warning.
It's not a big deal but coming from Erlang/Elixir the learning curve is pretty steep (as noted by @marick in #43) so I tried to look up what I actually did wrong.
Thanks!
See #89
When following the Purescript without Node guide, I get a compilation error of one of the dependencies:
purescript-test/dependencies/purescript-prelude/src/Prelude.purs line 41, column 10 - line 41, column 10
Unable to parse module:
unexpected $
expecting "type", qualifier, identifier or proper name
Using the following environment:
$ psc --version
0.9.3
$ cd ../purescript-prelude/
$ git log -n 1 --decorate=short
commit 5e1d34f6ee771a436286a0335c5de80343dfa6be (HEAD, tag: v0.1.0)
Merge: bfe859a f5d8b7c
Author: Gary Burgess <[email protected]>
Date: Sun Jun 14 12:46:33 2015 +0100
Merge pull request #29 from hdgarrood/ord-docs
Ord docs
$ cd dependencies/purescript-console/
$ git log -n 1 --decorate=short
commit d6654ac2b846982375c58d0b8829b495bc4d6b69 (HEAD, tag: v0.1.0-rc.1, tag: v0.1.0)
Author: Gary Burgess <[email protected]>
Date: Sat Jun 6 14:30:38 2015 +0100
Updates for RC
$ cd ../purescript-eff/
$ git log -n 1 --decorate=short
commit df0abe075321c660321e6aefcdff53052ced620f (HEAD, tag: v0.1.0-rc.2, tag: v0.1.0)
Merge: 1f48316 5038b75
Author: Phil Freeman <[email protected]>
Date: Tue Jun 9 11:38:44 2015 -0700
Merge pull request #3 from purescript/class
Move MonadEff over
I'm using the Main.purs
from the guide:
module Main where
import Control.Monad.Eff.Console (log)
main = log "Hello, World!"
The reason I reported this bug here is because I suspect that the problem is merely a version mismatch between the compiler and the dependencies.
This is the first time I'm using purescript, so I thought you'd be interested in a use case where this problem is encountered, from a documentation point of view.
Invoking pulp build throws 3 more missing type declarations
warnings #87 for Euler.purs
It have been asked a few times on IRC:
Either String Int
from JS?"MyCustomDatatype
from JS?"Two solutions that were brought up were to:
Left
, Right
, MyCustomDatatypeConstructor`, etc.),String :: Maybe MyCustomDatatype
that will get a string version of that constructor and will decide which value to return based on that.It'd be great if that'd be documented in the FFI guide. :)
Record literals and record updates are documented twice, for instance. I think we could remove the entire language/Records.md
file.
This is a bit of a disaster from a licensing perspective. As I understand it, the content of every accepted PR is All Rights Reserved by its original author. This means users only have the rights ensured by the GitHub TOS, such as to view, fork, etc. but not to use the content for any purpose, and not to redistribute it.
I would have liked this content to be permissively licensed, but it's a bit late now.
This leaves us with a few options:
Whatever we do, I would like to start requiring explicit licensing in some form for new contributions.
I am fetching api responce as a:
result = studentInfo: StudentInfo
{
department : ["Account", "Register", "Sport", "Social", "Hostel"]
,branch : {id : "001",name : "IT", count: 50 , year :2017}
}
and i will try to get only count value from branch and assing to simple number variable, but we can't get count value.
i am tring to get count value as a:
result.branch{count}
result.branch.count
result{branch{count}}
result{branch.count}
but its shows error "Could not match type"
how to get count value in purescript code.
please help me to resolved that issue.
There is one or two implementations of Data.Generic.Rep (class Generic)
, but no tutorial to help know-nothings make an instance of it for their data type. We should make a doc page in the Tutorials or Tasks category for this. It's based on GHC Generics, so we might be able to reference docs from that when writing docs for PureScript's.
This function is a really good idea and currently it's only mentioned in the generated API docs for purescript-partial
, AFAIK.
The syntax _.foo.bar
isn't mentioned anywhere.
The doc in question: https://github.com/purescript/documentation/blob/master/guides/PureScript-Without-Node.md
It uses the out of date psc
binaries, rather than the new purs
ones.
For now, I'll just post in PS documentation's issues, but we should upload this somewhere for collaboration. As a starting idea: make a directory in this repo called "Intro to Prelude", put this list into a file in it called "index", then update that file to link to videos as they are produced. Or, instead of simply linking to the video in the index file, we make a new file in that directory for each module in which to have proper documentation and a link to the video in which it appears.
I think we can have one grouping of modules to discuss at PS Unscripted each month, but we could do a different meetup/schedule for this if it's popular.
We also need a template to follow when organizing content for the videos, to ensure videos contain information essential to understanding a topic. As a start:
PSCi has a browser backend, doesn't it? It seems this repo doesn't have docs for it, yet. I recall working with a person several weeks ago who was struggling to use the jquery wrapper with the browser backend, but was getting really frustrated because there were no docs.
The "Getting Started" tutorial uses let
twice in PSCi. This throws an error, as
Declarations in PSCi no longer require "let", as of version 0.11.0
Copied from purescript/roadmap#50
I think we can remove quite a few pages:
Out of date/no longer necessary
Belong elsewhere
psc-ide
questions (same)(I couldn't find a better place to leave this comment - sorry.)
When I started learning Purescript, I wanted to find that place that documented all the "obvious" modules. The equivalent of Elm's http://package.elm-lang.org/packages/elm-lang/core/latest/ or https://hexdocs.pm/elixir/Kernel.html for Elixir. There was no obvious pointer to it. It was really just a guess that led me to try Pursuit from http://www.purescript.org/learn/. The text about Pursuit made it seem like (only) the package manager search site: the equivalent of http://package.elm-lang.org or https://hex.pm/packages or https://clojars.org -- not the place to find information everyone should know.
The code for guards example doesn't compile:
evens :: List Int -> Int
evens Nil = 0
evens (Cons x xs) | x % 2 == 0 = 1 + evens xs
evens (Cons _ xs) = evens xs
It gives:
Error 1 of 1
Could not match type
Int
with type
Number
while checking that type t0
is at least as general as type Number
while checking that expression x
has type Number
while checking the type of a guard clause
in binding group evens
where t0 is an unknown type
Before moving to a tool, we should list the advantages we would gain by moving to such a system. Using a GitHub repo for docs, as we are now, is kinda nice for several reasons.
Pros/cons of GitHub repo, no special doc site:
Pros
Cons
owickstrom said on Twitter that he has recently moved from pandoc (?) to sphinx for Hyper's docs. We can view Hyper's doc site as a preview of a PureScript doc site built using Sphinx.
An idea brought up by andrewc is a curated Purescript cookbook, for examples of things that are just marginally beyond “hello world”.
I agree. We could add a "Tasks" chapter, and curate it like Kubernetes' "Tasks" docs.
Our initial work would be to create a directory in this repo for it, then seed it with 1-3 task docs to provide a template for contributed tasks by the community. We can use one of andrewc's works as an example https://gist.github.com/afcondon/68265847902a3232f228b542d9fd296f
Specifically, only for operating systems where we do not provide binaries, eg, freebsd. See purescript/purescript#2463
I think some guides would probably be easier to find if they were put in the docs for the relevant libraries. For example:
purescript-partial
purescript-quickcheck
purescript-eff
(actually moved to purescript-effect
)purescript-generics-rep
I also think they'd be less likely to go out of date, as you're more likely to remember to update guides like this if they're right there when you're changing the code.
What do people think?
Since there's no command that actually is called "psci" any more (apart from pulp psci
, which is only there for backwards compatibility and is no longer documented), I think it would make sense to call it "the repl" in these docs instead.
We recently merged user-defined kinds, but I don't see any docs here for it. Is "foreign import kind" the new syntax? I would expect to find the docs in language/FFI.md.
Copied from purescript/roadmap#43
One part of learning a language is idioms. One way to learn a language's idioms is by seeing alternate ways of writing a thing.
For example:
logShow
, then discover traceAny
.>>=
, <$>
, and maybe >=>
is a better way.ContT
, then discover Aff
is better, or vice-versa.Either MultipleErrors a
, then discover clever use of ExceptT
is a bit better.MonadRec
or fix-point concepts are very helpful.These TILs would need to be structured, somehow. Perhaps by problem category?
Perhaps these TILs could be integrated into another hierarchy of docs, like alongside a curriculum having practice exercises for introducing these problem categories?
https://github.com/purescript/documentation/blob/master/language/Type-Classes.md says:
Overlapping instances are currently permitted but not recommended.
I get a compiler error-not-warning on an overlapping-instances situation, but from the above I the user can't tell for sure if this is now always an error, or whether there might be overlapping-instances cases still being permitted-but-warned-about. Thx!
Having mistakes such as those addressed by #69, e.g. examples left over from before PureScript had an Int
type, is a little embarrassing, in my view. I'd like to investigate some kind of script which ensures that code examples at least compile.
Now seems like a good time to remove the outdated content from the wiki. We should probably keep it active though, with links to the updated material.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.