Haskell

Synaptic > Haskell > STACK

https://github.com/DanielG/ghc-mod/wiki/Installing

Downloading the latest package list from hackage.haskell.org
ryoji@ubuntu:~/HackTheTower$ cabal install ghc-mod
Resolving dependencies...
Downloading ansi-wl-pprint-0.6.7.3...
Downloading base-orphans-0.6...
Configuring ansi-wl-pprint-0.6.7.3...
Downloading clock-0.7.2...
Configuring base-orphans-0.6...
Downloading cpphs-1.20.5...
Configuring clock-0.7.2...
Downloading djinn-lib-0.0.1.2...
Configuring cpphs-1.20.5...
Downloading dlist-0.8.0.2...
Downloading exceptions-0.8.3...
Downloading fail-4.9.0.0...
Downloading fclabels-2.0.3.2...
Downloading ghc-paths-0.1.0.9...
Downloading ghc-syb-utils-0.2.3.2...
Downloading lifted-base-0.2.3.11...
Downloading mmorph-1.1.0...
Downloading prelude-extras-0.4.0.3...
Downloading safe-0.3.14...
Downloading tagged-0.8.4...
Downloading utf8-string-1.0.1.1...
Downloading void-0.7.2...
Building ansi-wl-pprint-0.6.7.3...
Building cpphs-1.20.5...
Building clock-0.7.2...
Building base-orphans-0.6...
Installed ansi-wl-pprint-0.6.7.3
Configuring dlist-0.8.0.2...
Building dlist-0.8.0.2...
Configuring fail-4.9.0.0...
Installed clock-0.7.2
Downloading extra-1.5.3...
Building fail-4.9.0.0...
Configuring exceptions-0.8.3...
Installed fail-4.9.0.0
Downloading MonadRandom-0.5.1...
Configuring fclabels-2.0.3.2...
Installed dlist-0.8.0.2
...
Configuring hlint-2.0.9...
Building hlint-2.0.9...
Installed hlint-2.0.9
Downloading ghc-mod-5.8.0.0...
Configuring ghc-mod-5.8.0.0...
Building ghc-mod-5.8.0.0...
Installed ghc-mod-5.8.0.0

vim .xsessionrc

# add Cabal's bin directory to the executable search PATH if it exists
if [ -d "$HOME/.cabal/bin" ] ; then
    PATH="$HOME/.cabal/bin:$PATH"
fi
ryoji@ubuntu:~$ ghci
GHCi, version 7.10.3: http://www.haskell.org/ghc/  :? for help
Prelude> 1 * 2
2
Prelude> :t 1
1 :: Num a => a
Prelude> :t return 1
return 1 :: (Monad m, Num a) => m a

Prelude> putStrLn "hello"
hello
Prelude> x <- return 42 //https://downloads.haskell.org/~ghc/7.8.4/docs/html/users_guide/interactive-evaluation.html
Prelude> print x
42

simply means

print `return 42`

https://stackoverflow.com/questions/5417623/ghci-not-in-scope-message
http://learnyouahaskell.com/syntax-in-functions

module

bmi :: Floating a => a -> a -> a
bmi weight height = weight / height ^ 2
..<interactive>:21:1: Not in scope:

is equivalent to like scala's

def bmi(<?>: of Floating, <?>: of Floating): <?> = {
  ? / ? ^ 2
}
def bmiImpl(weight: Double, height: Double): Double = {
  weight / height ^ 2
}

map. generics. monad

Prelude> let lucky x = show (x + 1)
Prelude> :t lucky
lucky :: (Num a, Show a) => a -> String
Prelude> lucky 1
"2"
Prelude> let bmi weight height = weight / height ^ 2
Prelude> bmi 80 2.0
20.0

Prelude> :show bindings
x :: Integer = 42
lucky :: (Num a, Show a) => a -> String = _
bmi :: Fractional a => a -> a -> a = _

stack

ryoji@ubuntu:~$ stack setup
Run from outside a project, using implicit global project config
Using resolver: lts-8.18 from implicit global project's config file: /home/ryoji/.stack/global-project/stack.yaml
Preparing to install GHC to an isolated location.
This will not interfere with any system-level installation.
Downloaded ghc-8.0.2.                                      
Installed GHC.                               
stack will use a locally installed GHC
For more information on paths, see 'stack path' and 'stack exec env'
To use this GHC and packages outside of a project, consider using:
stack ghc, stack ghci, stack runghc, or stack exec
stack upgrade
...
Registering stack-1.4.0...
Completed all 173 actions.
Copying from /tmp/stack-upgrade6391/stack-1.4.0/.stack-work/install/x86_64-linux/lts-6.25/7.10.3/bin/stack to /home/ryoji/.local/bin/stack

Copied executables to /home/ryoji/.local/bin:
- stack

runhaskell.png

ryoji@ubuntu:/$ cabal install statistics
Resolving dependencies...
Downloading math-functions-0.2.1.0...
Configuring math-functions-0.2.1.0...
Building math-functions-0.2.1.0...
Installed math-functions-0.2.1.0
Downloading statistics-0.14.0.2...
Configuring statistics-0.14.0.2...
Building statistics-0.14.0.2...
Installed statistics-0.14.0.2
ryoji@ubuntu:/$ cabal install statistics
Resolving dependencies...
Downloading math-functions-0.2.1.0...
Configuring math-functions-0.2.1.0...
Building math-functions-0.2.1.0...
Installed math-functions-0.2.1.0
Downloading statistics-0.14.0.2...

https://www.reddit.com/r/haskell/comments/r5dxn/please_critique_my_very_simple_bmi_calculator/
https://www.schoolofhaskell.com/school/to-infinity-and-beyond/pick-of-the-week/Simple%20examples

stack install ghc-mod
stack install hlint
stack install phoityne-vscode
stack install intero QuickCheck stack-run
stack install stylish-haskell
14:31	ghc-mod
			Attempting to use a ghc-mod compiled with a different version of ghc:
			GHC version: '7.10.3'
			ghc-mod compiled with ghc version: '8.0.2'
			Please reconfigure ghc-mod to use a version compiled with GHC 7.10.3
ryoji@ubuntu:~$ ghc-mod --version
ghc-mod version 5.7.0.0 compiled by GHC 8.0.2
ryoji@ubuntu:~$ stack ghc
ghc: no input files
Usage: For basic information, try the `--help' option.
ryoji@ubuntu:~$ stack ghci
Configuring GHCi with the following packages: 
GHCi, version 8.0.2: http://www.haskell.org/ghc/  :? for help
Loaded GHCi configuration from /tmp/ghci14477/ghci-script
Prelude> :quit
Leaving GHCi.
ryoji@ubuntu:~$ stack new my-project
Downloading template "new-template" to create project "my-project" in my-project/ ...

The following parameters were needed by the template but not provided: author-email, author-name, category, copyright, github-username
You can provide them in /home/ryoji/.stack/config.yaml, like this:
templates:
  params:
    author-email: value
    author-name: value
    category: value
    copyright: value
    github-username: value
Or you can pass each one as parameters like this:
stack new my-project new-template -p "author-email:value" -p "author-name:value" -p "category:value" -p "copyright:value" -p "github-username:value"

Looking for .cabal or package.yaml files to use to init the project.
Using cabal packages:
- my-project/my-project.cabal

Selecting the best among 10 snapshots...

* Matches lts-8.18

Selected resolver: lts-8.18
Initialising configuration using resolver: lts-8.18
Total number of user packages considered: 1
Writing configuration to file: my-project/stack.yaml
All done.

https://docs.haskellstack.org/en/stable/README/

    last modified: 18 June 2017 [ View wiki source Close ]
     
SEARCH DIFFERENCE ATTACHMENT RECENT POST