Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Haskell High Performance Programming
  • Table Of Contents Toc
  • Feedback & Rating feedback
Haskell High Performance Programming

Haskell High Performance Programming

By : Thomasson
3 (2)
close
close
Haskell High Performance Programming

Haskell High Performance Programming

3 (2)
By: Thomasson

Overview of this book

Haskell, with its power to optimize the code and its high performance, is a natural candidate for high performance programming. It is especially well suited to stacking abstractions high with a relatively low performance cost. This book addresses the challenges of writing efficient code with lazy evaluation and techniques often used to optimize the performance of Haskell programs. We open with an in-depth look at the evaluation of Haskell expressions and discuss optimization and benchmarking. You will learn to use parallelism and we'll explore the concept of streaming. We’ll demonstrate the benefits of running multithreaded and concurrent applications. Next we’ll guide you through various profiling tools that will help you identify performance issues in your program. We’ll end our journey by looking at GPGPU, Cloud and Functional Reactive Programming in Haskell. At the very end there is a catalogue of robust library recommendations with code samples. By the end of the book, you will be able to boost the performance of any app and prepare it to stand up to real-world punishment.
Table of Contents (21 chapters)
close
close
Haskell High Performance Programming
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Trivia at type-level


The more expressive the types are, the more safety we can ensure at compile-time. What's more, expressive types serve as documentation that is always up-to-date.

Phantom types

A type that has type variables on the left-hand side that do not appear on the right-hand-side at all is called a phantom type. Such type variables are a cheap, in fact free, technique to guarantee correctness in multiple situations. An example from base is Data.Fixed, in which the precision of fixed-precision arithmetic is encoded in a phantom type.

An extremely useful class of phantom types is obtained in conjunction with Generalized Algebraic Data Types (GADT). As a little silly example, consider:

-- file: gadts.hs
{-# LANGUAGE GADTs #-}data Value a where
    Boolean :: Bool -> Value Bool
    Not     :: Value Bool -> Value Bool
    Numeric :: Num a => a -> Value a
    Sum     :: Num a => Value a -> Value a -> Value a

The first two constructors allow us to build values that contain...

Limited Time Offer

$10p/m for 3 months

Get online access to our library of over 7000 practical eBooks and videos, constantly updated with the latest in tech and supported with AI assistants
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist download Download options font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon

Create a Note

Modal Close icon
You need to login to use this feature.

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete

Delete Note

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete

Edit Note

Modal Close icon
Write a note (max 255 characters)
Cancel
Update Note