Code Snippets Haskell

Short texts Haskell 🧑‍💻 Code snippets Haskell ✍️ Reading lists Haskell 👀

AdaCard Prize Payout

{-# LANGUAGE OverloadedStrings #-} module Example where import Language.Marlowe.Extended import Plutus.V1.Ledger.Value main :: IO () main = print . pretty $ contract 1 “AdaCard1234” contract :: Integer -> TokenName -> Contract contract minLovelace tokenName = When [Case (Deposit (Role “adafolio”) (Role “adafolio”) (Token “1234abcd” tokenName) (Constant 1) ) (When [Case (Deposit (Role “adafolio”) (Role “winner”) […]

Plutus Playground Smart Contract

— This is a starter contract, based on the Game contract, — containing the bare minimum required scaffolding. — — What you should change to something more suitable for — your use case: — * The MyDatum type — * The MyRedeemer type — — And add function implementations (and rename them to — something […]

hmmm

{-# LANGUAGE GADTs,LambdaCase,RankNTypes #-} module Lib where import Prelude hiding (succ, fromIntegral) type Digit n = (Num n, Eq n, Show n) => n data Nat where S :: (Eq n, Eq z, Show n, Show z, Num n, Num z, n ~ z) => Digit z -> Digit n -> Nat Z :: () […]

Plutus Playground Smart Contract

import qualified Data.Text as T import Playground.Contract import Plutus.Contract import PlutusTx.Prelude import qualified Prelude as Haskell — | A ‘Contract’ that logs a message. — | Java comparison of function below — public Contract(BlockchainActions, T.Text, void) hello(){ — return logInfo(@String “Hello, world”); — } hello :: Contract () EmptySchema T.Text () hello = logInfo @Haskell.String […]

FiniteDomain Monadic Constraint Solver

{-# LANGUAGE StandaloneDeriving #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE FlexibleInstances #-} module FDMCS where –import Control.Monad import Prelude (Num(..), Show(..), Integral(..), fromIntegral, ($!), undefined) import qualified Prelude as P import Control.Applicative (Applicative(pure, ()), Alternative) import Control.Monad import Control.Monad.State.Strict (State(..), StateT(..), MonadState(..), evalStateT) import qualified Control.Monad.State.Strict as State import Data.Bool (Bool(..), (&&), not, otherwise) import […]