Haskell – 120 – altre monadi ancora – 1

Continuo da qui, copio qui.

We’ve seen how monads can be used to take values with contexts and apply them to functions and how using >>= or do notation allows us to focus on the values themselves while the context gets handled for us.

We’ve met the Maybe monad and seen how it adds a context of possible failure to values. We’ve learned about the list monad and saw how it lets us easily introduce non-determinism into our programs. We’ve also learned how to work in the IO monad, even before we knew what a monad was!

Now we’re going to learn about a few other monads. We’ll see how they can make our programs clearer by letting us treat all sorts of values as monadic ones. Exploring a few monads more will also solidify our intuition for monads.

The monads that we’ll be exploring are all part of the mtl package. A Haskell package is a collection of modules. The mtl package comes with the Haskell Platform, so you probably already have it. To check if you do, type ghc-pkg list in the command-line. This will show which Haskell packages you have installed and one of them should be mtl, followed by a version number.

* hs-120 $ ghc-pkg list
/usr/lib/ghc/package.conf.d
    Cabal-1.24.2.0
    array-0.5.1.1
    base-4.9.1.0
    binary-0.8.3.0
    bytestring-0.10.8.1
    containers-0.5.7.1
    deepseq-1.4.2.0
    directory-1.3.0.0
    filepath-1.4.1.1
    ghc-8.0.2
    ghc-boot-8.0.2
    ghc-boot-th-8.0.2
    ghc-prim-0.5.0.0
    ghci-8.0.2
    haskeline-0.7.3.0
    hoopl-3.10.2.1
    hpc-0.6.0.3
    integer-gmp-1.0.0.1
    pretty-1.1.3.3
    process-1.4.3.0
    rts-1.0
    template-haskell-2.11.1.0
    terminfo-0.4.0.2
    time-1.6.0.1
    transformers-0.5.2.0
    unix-2.7.2.1
    xhtml-3000.2.1

Panico 😐 manca 😡

Provo a installarlo, seguendo le dritte qui e qui.

* hs-120 $ cabal update
Il programma "cabal" non è attualmente installato. È possibile installarlo digitando:
sudo apt install cabal-install
* hs-120 $ sudo apt install cabal-install

e parte l’installazione ma poi

* hs-120 $ cabal install mtl
Config file path source is default config file.
Config file /home/juhan/.cabal/config not found.
Writing default configuration to /home/juhan/.cabal/config
Warning: The package list for 'hackage.haskell.org' does not exist. Run 'cabal
update' to download it.
cabal: There is no package named 'mtl'.
You may need to run 'cabal update' to get the latest list of available
packages.

Allora…

* hs-120 $ cabal update
Downloading the latest package list from hackage.haskell.org
* hs-120 $

e…

* hs-120 $ ghc-pkg list | grep mtl
* hs-120 $

niente da fare!

Ma riprovo:

* hs-120 $ cabal update
Downloading the latest package list from hackage.haskell.org
Skipping download: local and remote files match.
* hs-120 $ cabal install mtl
Resolving dependencies...
Downloading mtl-2.2.1...
Configuring mtl-2.2.1...
Building mtl-2.2.1...
Installed mtl-2.2.1
* hs-120 $

e adesso

* hs-120 $ ghc-pkg list | grep mtl
    mtl-2.2.1
* hs-120 $

OK, è stata dura 😐 pausa 😯

🤣

Posta un commento o usa questo indirizzo per il trackback.

Trackback

Rispondi

Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:

Logo WordPress.com

Stai commentando usando il tuo account WordPress.com. Chiudi sessione /  Modifica )

Google+ photo

Stai commentando usando il tuo account Google+. Chiudi sessione /  Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione /  Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione /  Modifica )

Connessione a %s...

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d blogger hanno fatto clic su Mi Piace per questo: