Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Haskell Cookbook

You're reading from   Haskell Cookbook Build functional applications using Monads, Applicatives, and Functors

Arrow left icon
Product type Paperback
Published in Sep 2017
Publisher Packt
ISBN-13 9781786461353
Length 396 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Yogesh Sajanikar Yogesh Sajanikar
Author Profile Icon Yogesh Sajanikar
Yogesh Sajanikar
Arrow right icon
View More author details
Toc

Table of Contents (19) Chapters Close

Title Page
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface
1. Foundations of Haskell FREE CHAPTER 2. Getting Functional 3. Defining Data 4. Working with Functors, Applicatives, and Monads 5. More about Monads 6. Working with Common Containers and Strings 7. Working with Relational and NoSQL Databases 8. Working with HTML and Templates 9. Working with Snap Framework 10. Working with Advanced Haskell 11. Working with Lens and Prism 12. Concurrent and Distributed Programming in Haskell

Using hashsets and sorted sets in redis to create a Trie


In this recipe, we will be using hedis to create simple trie in Redis. We will a use hashset to store an object, and store its searchable index in the sorted set in redis. We will be using the prefix trie to create a searchable index. For example, if we are searching for "APPLE", we will index all prefixes ("A","AP","APP","APPL", and "APPLE") in the index. Whenever a user enters a string to search, we will be able to look up our index and get the result.

Getting ready

Start the Redis server, and note down the connection info. In this recipe, we will assume that Redis is working on the same machine at the port 6379. This is what hedis assumes to connect to the Redis server using the default connection information.

How to do it...

  1. Create a new project called hedis-trie with a simple stack template:
        stack new hedis-trie simple
  1. Add a dependency on the hedis library in the build-depends sub-section of the executable section:
        executable...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime
Visually different images