Comments (9)
I think that input should be accepted. You could work-around it for now and write:
let doubleIt :: Int -> Int
doubleIt x = x*2
I think the issue is that doubleIt :: Int -> Int
can parse as a statement (think helloWorld :: IO ()
), or as a declaration. IHaskell.Eval.Evaluate.parseCommands
classifies doubleIt :: Int -> Int
as a statement.
from ihaskell.
This is something I would consider a bug, and should be fixed. The
workaround is okay for now, but I think this I will make this fixed when I
switch to ghc api for parsing.
from ihaskell.
I don't think ghc's parser knows how to tell the difference: ghci doesn't accept Carreau's input without the let. To expand on how things are ambiguous:
helloWorld = putStrLn "hello world"
helloWorld :: IO ()
If you put that into a file, the helloWorld :: IO ()
specifies the type. In IHaskell that's currently rejected, but it could be asking to evaluate the IO, or it could be a type signature just like in a file.
Maybe it is better to classify the whole chunk as having only declarations or only statements.
from ihaskell.
I can't judge as I have probably not written more than 50 lines of Haskell in my life. But it is confusing when following a tutorial and just copy-pasting example.
But I guess that how python newbies feel when they spawn class declaration across multiple cell in notebook and it does not work.
So I'll let you guy decide ,let
is fine for me for the time beeing :-)
from ihaskell.
Another option: allow declarations immediately before the definitions?
On Oct 29, 2013 1:12 PM, "Adam Vogt" [email protected] wrote:
I don't think ghc's parser knows how to tell the difference: ghci doesn't
accept Carreau's input without the let. To expand on how things are
ambiguous:helloWorld = putStrLn "hello world"
helloWorld :: IO ()If you put that into a file, the helloWorld :: IO () specifies the type.
In IHaskell that's currently rejected, but it could be asking to evaluate
the IO, or it could be a type signature just like in a file.Maybe it is better to classify the whole chunk as having only declarations
or only statements.—
Reply to this email directly or view it on GitHubhttps://github.com//issues/25#issuecomment-27338924
.
from ihaskell.
Do you mean, asking Haskell spec to change or actually trying to hack something for it to work ?
from ihaskell.
@Carreau the haskell spec doesn't describe what ghci is supposed to do.
@gibiansky yeah we could resolve the ambiguity in favor of sigD
if you have a valD
or funD
(to use template-haskell's names) that defines the same Name
right above/below.
from ihaskell.
@Carreau the haskell spec doesn't describe what ghci is supposed to do.
What I ment is that maybe the Haskell spec suppose a "file" is compiled in one block
and does not accomodate for REPL. So maybe this is and ambiguity should not even
try to resolve or at least try to have this case beeing a standard in spec ?
When Julia Guys came to bind to the notebook, we were missunderstanding some stuff, because
they were both wondering if they should change thing in Julia
or in julia
(lower case being the
reference implementation of the interpreter, and Uppercase being the spec) They ended up changing both
and actually buiding feature into the language itself.
from ihaskell.
This should be fixed in commit a6dd856
The way this currently works is that a type declaration of that form is always parsed as a declaration, not an expression. Although this is a bit ambiguous, it can be resolved by putting it in parentheses if necesary:
doubleIt :: Int -> Int -- Declaration
(doubleIt :: Int -> Int) -- Expression
Declarations after that must be followed by the appropriate definition.
from ihaskell.
Related Issues (20)
- Cannot allocate memory HOT 3
- Package not include: Failed to Build
- HLS for GHC 9 HOT 4
- nix run github:IHaskell/IHaskell#ihaskell -- install HOT 2
- ihaskell-diagrams-0.3.2.1 fails to build HOT 4
- Adding packages HOT 1
- Update `IHaskell.IPython.EasyKernel.installKernelspec` to use `jupyter` instead of `ipython` HOT 1
- New ghc-parser release? HOT 3
- Installation Fails in Apple Silicon MacBook HOT 6
- Nix instructions seem wildly out of date HOT 1
- Cannot install because of missing file on GitHub HOT 6
- Jupyter cannot connect to kernel from outside IHaskell folder. HOT 2
- Tests run "forever" HOT 5
- Notebooks don't correctly update the status of input cells HOT 3
- `jupyterlab-ihaskell` does not support JupyterLab 4.x HOT 1
- When installing from nix flake the ihaskell kernel does not become available in jupyter HOT 2
- IHaskell.Display.Widgets not available when using Nix packages HOT 3
- `nix/release.nix` doesn't work after #1425 HOT 1
- IHaskell not building on macOS HOT 2
- No persistent command history in jupyter console HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ihaskell.