Skip to content

Instantly share code, notes, and snippets.

View lsmor's full-sized avatar

Luis Morillo lsmor

View GitHub Profile

Set Up a Haskell Development Environment in Three Steps

a Haskell Development Environment consist in a compiler (ghc), a language server (hls), a building tool (cabal or stack), and an editor compatible with the language server protocol.

The best way to have a coherent installation of these components is with the ghcup tool.

  • Step 1: Install GHCup. You'll be prompted to install some tools. Say yes to hls. Do not install stack yet (see below).
  • Step 2: Install vscode
  • Step 3: Open vscode and install the haskell extension either using the extension panel or pressing CTRL+P and ext install haskell.haskell.
@lsmor
lsmor / Playground.hs
Last active March 13, 2021 19:33
Plutus Playground Smart Contract
import Control.Monad (void, when)
import qualified Data.Map.Strict as Map
import qualified Data.Text as T
import Data.Set (Set, (\\), fromList, toList, size)
import Data.Functor ((<&>))
import Data.Foldable (foldl')
import Data.List (sortOn)
import Data.Ord (Down)
import Language.Plutus.Contract hiding (when)
@lsmor
lsmor / Playground.hs
Last active March 12, 2021 18:29
Plutus Playground Smart Contract
-- A game with two players. Player 1 thinks of a secret word
-- and uses its hash, and the game validator script, to lock
-- some funds (the prize) in a pay-to-script transaction output.
-- Player 2 guesses the word by attempting to spend the transaction
-- output. If the guess is correct, the validator script releases the funds.
-- If it isn't, the funds stay locked.
import Control.Monad (void, when)
import qualified Data.Map as Map
import qualified Data.Text as T
@lsmor
lsmor / Playground.hs
Created March 11, 2021 20:08
Plutus Playground Smart Contract
-- A game with two players. Player 1 thinks of a secret word
-- and uses its hash, and the game validator script, to lock
-- some funds (the prize) in a pay-to-script transaction output.
-- Player 2 guesses the word by attempting to spend the transaction
-- output. If the guess is correct, the validator script releases the funds.
-- If it isn't, the funds stay locked.
import Control.Monad (void)
import qualified Data.ByteString.Char8 as C
import Language.Plutus.Contract
import qualified Language.PlutusTx as PlutusTx