The main package manager to use in Haskell is Cabal. Make sure that the Cabal version that you are using is at
least 3.0. Then build, repl, install, etc will use the upgraded v2-style versions that work with minimal problems.
Documentation
| {-# LANGUAGE DeriveFoldable #-} | |
| {-# LANGUAGE DeriveFunctor #-} | |
| {-# LANGUAGE DeriveTraversable #-} | |
| {-# LANGUAGE KindSignatures #-} | |
| {-# LANGUAGE TemplateHaskell #-} | |
| {-# LANGUAGE TypeFamilies #-} | |
| module Main where | |
| import Data.Foldable (fold) | |
| import Data.Functor.Foldable (cata, embed, hylo) |
| module Main where | |
| import Control.Concurrent.Async (async, wait) | |
| import Control.Exception (Exception, catch, throwIO) | |
| import Control.Monad.IO.Class (liftIO) | |
| import Control.Monad.Trans.Class (lift) | |
| import Control.Monad.Trans.Except (ExceptT (ExceptT), runExceptT) | |
| import Control.Monad.Trans.Resource (ResourceT, allocate, release, runResourceT) | |
| newtype MyException = MyException String deriving Show |
| #lang racket/base | |
| (require racket/async-channel racket/future ffi/unsafe/os-thread) | |
| (define (mandelbrot iterations x y n) | |
| (let ([ci (- (/ (* 2.0 y) n) 1.0)] | |
| [cr (- (/ (* 2.0 x) n) 1.5)]) | |
| (let loop ([i 0] [zr 0.0] [zi 0.0]) | |
| (if (> i iterations) | |
| i |
| (require syntax/parse/define | |
| (for-syntax racket/base racket/syntax)) | |
| (define-syntax-parser v! | |
| #:datum-literals (:=) | |
| [(_ vec:id [e:expr ...]) #'(~> vec (vector-ref e) ...)] | |
| [(_ vec:id [e:expr ...] := exp:expr) | |
| (define es (syntax-e #'(e ...))) | |
| #`(~> vec | |
| #,@(for/list ([i (in-range 0 (length es))] |
| (defmacro make-table (sym &rest kvs) | |
| (let* ((hash-sym (gensym)) | |
| (setters (iter (for (k v) in kvs) | |
| (collect `(setf (gethash ,k ,hash-sym) ,v))))) | |
| `(defmacro ,sym () | |
| (let ((,hash-sym (make-hash-table))) | |
| ,@setters | |
| ,hash-sym)))) | |
| (defmacro get-table (sym k) |
| (define-syntax (: stx) | |
| (syntax-parse stx | |
| ; #:literals needs to have bindings in order to work | |
| ; #:datum-literals only needs symbols so it works with '^'. | |
| #:datum-literals (+ - * / ^) | |
| [(_ l ... + r ...) #'(+ (: l ...) (: r ...))] | |
| [(_ l ... - r ...) #'(- (: l ...) (: r ...))] | |
| [(_ l ... * r ...) #'(* (: l ...) (: r ...))] | |
| [(_ l ... / r ...) #'(/ (: l ...) (: r ...))] | |
| [(_ l ... ^ r ...) #'(expt (: l ...) (: r ...))] |
| {- cabal: | |
| build-depends: base >= 4.11 && < 5,shelly,text | |
| ghc-options: -Wall -O0 | |
| default-language: Haskell2010 | |
| -} | |
| {-# LANGUAGE OverloadedStrings #-} | |
| module Main where | |
| import Shelly |
| {-# LANGUAGE DataKinds #-} | |
| {-# LANGUAGE FlexibleContexts #-} | |
| {-# LANGUAGE MonoLocalBinds #-} | |
| {-# LANGUAGE TypeApplications #-} | |
| {-# LANGUAGE TypeOperators #-} | |
| module Main where | |
| import Control.Monad.Except | |
| import Control.Monad.Identity | |
| import Data.Bifunctor |