Skip to content

rafald/Haskell-notes

Repository files navigation

How to introduce new dependencies

new stack template based projects use package.yaml to specify dependencies ; .cabal file is derived from package.yaml so external dependencies should be specified in package.yaml, not in .cabal or stack.yaml If packahge is not present add for instance build-depends: yesod -any, composition -any, to cabal file. There are two sections: library: and executable: Executable seems to be proper place in case of IHaskell

This is manual task - no support from stack tool. This entails using ghc-pkg unregister and then finding the location of the package on your system and removing it via another tool or simply rm.

stack install <package name>
# Now remove the package
ghc-pkg unregister <pkg-id>
cd /path/to/stack/packages # This could be something like ~/.local/bin, but is configuration dependent
rm <package name>

Packages installed by stack are located deep within ~/.stack/snapshots/x86_64-linux/lts-8.0/8.0.2/

How to install on ubuntu

Plugin ide-haskell to install. It depends on language-haskell plugin so you must install it as well.

Assuming you have installed at least minimal Haskell toolchain , execute the following:

stack install stylish-haskell # binary deps required by ide-haskell plugin
stack install ghc-mod
stack install hlint
apm install language-haskell haskell-ghc-mod ide-haskell-cabal ide-haskell autocomplete-haskell

if necessary, alter PATH to include $HOME/.local/bin so stylish-haskelletc can be run

export PATH="$HOME/.local/bin:$PATH"

let expression let variable = expression in expression. This can be used wherever an expression is allowed, e.g.

   (let x = 2 in x*2) + 3

let-statement This form is only used inside of do-notation, and does not use in.

   do statements
     let variable = expression
     statements

let inside of list comprehensions Similar to number 2, again, no in.

    [(x, y) | x <- [1..3], let y = 2*x]

[(1,2),(2,4),(3,6)]

let vs where

The {assignments} are in scope for the expressions bar and baz, but not for foo.

[ baz | foo, let {assignments ; asss2 }, bar ]
> [ (x,v) | x <-[1..3], let {r = 1 ; g = [4..6] }, v <- g ]
[(1,4),(1,5),(1,6),(2,4),(2,5),(2,6),(3,4),(3,5),(3,6)]

the scope of where lines up with a particular function definition. So

someFunc x y | guard1 = blah1
             | guard2 = blah2
  where {assignments}

the {assignments} in this where clause have access to x and y. guard1, guard2, blah1, and blah2 all have access to the {assignments} of this where clause. This can be helpful if multiple guards reuse the same expressions


to suck in hs files to a new project:

  1. prepare packages.yaml - specify src dir
  2. run: stack init --solver --force

! only files starting with UPPERCASE will be incorporated

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published