ABOUT THIS EPISODE
Returning actual Data in Json
Resources
Follow
-
Building out some hardcoded users
-
need to supply
Userbefore the data -
don’t forget the
=sign -
We could manually build the encode and decode to/from JSON, but Generics, lets you automatically do things based on the data type
-
adding
{-# LANGUAGE DeriveGeneric #-}andimport GHC.Generics -
don’t forget to add
instance -
instance ToJSON User instance FromJSON User
-
Now we are able to see the output of having the generic encoder
Ok, two modules loaded.
*Main Lib> import Data.Aeson (encode)
*Main Lib Data.Aeson> encode bob
"{\"userName\":\"Bobby Boy\",\"userId\":1}"
- And now with that it looks like Scotty has a function json for use to return a json payload. sweet
get "/users" $ do
json allUsers
- JavaScript to Haskell
- Twitter: @jstoHaskell()
- Site: JSToHaskell
- microblog: [@jtomchak](https://micro.blog/jtomchak)
- Jesse Tomchak
English
United States
TRANSCRIPT 🔗
Are you the producer of this podcast?
Add a podcast transcript
Need Audio-to-Text?
Transcribe with Listen411 in Just 60 Seconds
SEARCH PAST EPISODES
Search past episodes of JavaScript to Haskell.
OTHER EPISODES IN THIS PODCAST
Episode 1:
Learning path github.com/bitemyapp…
Functional
Two values of functional
Functions are first-class, that is, functions are values which can be used in exactly the same ways as any other sort of value.
The meaning of Haskell programs is …
02: Haskell Tools
Install
stack looks to be the sort of NPM of haskell
reproduceable builds,
YAML file config. cabal config too
Command Line
stack build and then stack exec hello-world-exe
the build will create an executable in the ./stack-work and look ther…
04: Practical Haskell
So, following the book is hard. I don’t really learn well that way. I have just enough knowledge that the first part feels boring and repetitive, but I don’t know what I don’t know, so where do I pick up, chapter 2 or maybe 3? So let’s take this from a real JS perspective.
…
03: Lists
Handling Lists
Before we get started a couple tips for shorthand in Prelude
* > GHCi is an interactive Haskell REPL (Read-Eval-Print-Loop) that comes with GHC. At the GHCi prompt, you can evaluate expressions, load Haskell files with :load (:l) (and reload them with :relo…
Disclaimer: The podcast and artwork embedded on this page are from Jesse Tomchak, which is the property of its owner and not affiliated with or endorsed by Listen Notes, Inc.
EDIT
Thank you for helping to keep the podcast database up to date.