SlideShare a Scribd company logo
-- GHCi --
More Awesome
Than You (I?) Thought
Richard Minerich
Senior Researcher at Bayard Rock
@Rickasaurus
Noob Answers for
Noob Questions
How do I allow multi-line definitions?
Wrap it in “:{ 
 :}” or “:set +m”
Why doesn’t it show the type of my result?
“:set +t” will enable type info.
Why won’t my Haskell code execute in GHCi?
GHCi uses the monad “let” syntax.
How do I specify the type of something?
Follow it with “:: type” (e.g x = 5 :: Int)
Setup for this talk
Sublime Text 2 with
- SublimeHaskell
- SublimeREPL (head)
- Tabs to Spaces on
Haskell Platform (2012.4.0.0) with
aeson, haskell-src-exts, haddock,
ghc-mod, stylish-haskell, haskell-docs
SublimeREPL
SublimeREPL (as of last week) will now:
- Intelligently remove extra whitespace in
front of nested functions
- Prepends “let “ to functions sent to the REPL
and indents the remainder (as needed)
- Automatically wraps multi-line functions with
the new block syntax :{ .. :}
Haskell for Scripting
-- script.hs --
#!/usr/bin/env runhaskell
main = putStrLn “Hello, or something
”
On Windows:
runhaskell script.hs
On Posix:
./script.hs
GHCi Custom Configs
Search Paths:
:set +t
:def hoogle str ->
return $ ":! hoogle --count=15 "" ++ str ++ """
Tons of useful macros at the wiki:
http://www.haskell.org/haskellwiki/GHC/GHCi
./.ghci $HOME/.ghc/ghci.conf
appdata/ghc/ghci.conf $HOME/.ghci
Play with Language Flags
{-# LANGUAGE NoMonomorphismRestriction #-}
Vs.
:set –XNoMonomorphismRestriction
Vs.
(in latest Haskell Platform)
:seti –XNoMonomorphismRestriction
Loading Modules
By default module Dir.Module is Dir/Module.hs
:load Dir.Module Load compiled if exists
:load *Dir.Module Load interpreted forced
:reload Reloads target set
:show modules List loaded modules
Compiled vs. Interpreted
Compiled Interpreted
~10x Faster Execution ~2x Faster Load
Dependencies must be
compiled
Dependencies compiled
or interpreted
Only exports available Exports or full scope
“:! ghc –c Module.hs” Noop
Controlling GHCi Scope
:show imports
Shows what’s in scope
:module – Dir1.Module1 

Remove “./Dir1/Module1.hs” from scope
:module + Dir1.Module1 *Dir2.Module2 

Open exports from “./Dir1/Module1.hs”
Open full scope from “./Dir2/Module2.hs”
Standard import syntax applies as well
Your Eyes and Ears
:browse Module - Shows a module’s exports
:browse *Module – Shows full Module scope
:show bindings – List bound variables with type
:type <expr> - Type information for an expr
:info <name> - Extended information
:print <id> - Print without forced evaluation
:force <id> - Print with forced evaluation
GHCi Funny Business
GHCi is a monad, monad syntax applies (kind of)
Bindings go away after “:load” or “:reload”
Type defaults (are strange)
It’s thunks all the way down
“print” vs “:print” vs “:sprint” vs “:force”
Things to know about Debugging
All the standard stuff:
- Breakpoints, Break on Exception, Stepping
And some fancy stuff:
- Time Travel, Subexpression Breakpoints
But, some oddities (coming from other langs):
- Scope, Execution Ordering, :Print Breakpoints
Review: Debugging Basics
:set stop :list
:break [<id>] or [<module?> <line?> <col?>]
:show breaks
:delete <breakpoint_id|*>
:step <expr?> / :steplocal / :stepmodule
:abandon / :continue
:print <id> / :force <id>
Review: Time Travel Wizardry
:trace <expr>
:hist <num?>
:back / :forward
:show context
:set –fbreak-on-exception
:set –fbreak-on-error
_result / _exception
How the heck do I trace?
Remember, Haskell is lazy. So be thoughtful:
- Break inside, near the end
- Leverage assertions with error
(import Control.Exception (assert))
- Give BangPatterns a go
- Debug from a secondary .hs file
- Implement conditional breakpoints
That was just the tip of the iceburg, see the
Docs and Wiki for MUCH more information.

More Related Content

What's hot

Rust vs C++
Rust vs C++Rust vs C++
Rust vs C++
corehard_by
 
Initial Java Core Concept
Initial Java Core ConceptInitial Java Core Concept
Initial Java Core Concept
Rays Technologies
 
Scalaz By Example (An IO Taster) -- PDXScala Meetup Jan 2014
Scalaz By Example (An IO Taster) -- PDXScala Meetup Jan 2014Scalaz By Example (An IO Taster) -- PDXScala Meetup Jan 2014
Scalaz By Example (An IO Taster) -- PDXScala Meetup Jan 2014
Susan Potter
 
Go Lang Tutorial
Go Lang TutorialGo Lang Tutorial
Go Lang Tutorial
Wei-Ning Huang
 
Go. Why it goes
Go. Why it goesGo. Why it goes
Go. Why it goes
Sergey Pichkurov
 
DConf 2016: Keynote by Walter Bright
DConf 2016: Keynote by Walter Bright DConf 2016: Keynote by Walter Bright
DConf 2016: Keynote by Walter Bright
Andrei Alexandrescu
 
Let's talks about string operations in C++17
Let's talks about string operations in C++17Let's talks about string operations in C++17
Let's talks about string operations in C++17
Bartlomiej Filipek
 
C sharp 8.0 new features
C sharp 8.0 new featuresC sharp 8.0 new features
C sharp 8.0 new features
Miguel Bernard
 
Empty Base Class Optimisation, [[no_unique_address]] and other C++20 Attributes
Empty Base Class Optimisation, [[no_unique_address]] and other C++20 AttributesEmpty Base Class Optimisation, [[no_unique_address]] and other C++20 Attributes
Empty Base Class Optimisation, [[no_unique_address]] and other C++20 Attributes
Bartlomiej Filipek
 
The best language in the world
The best language in the worldThe best language in the world
The best language in the world
David Muñoz Díaz
 
The best of AltJava is Xtend
The best of AltJava is XtendThe best of AltJava is Xtend
The best of AltJava is Xtend
takezoe
 
Golang iran - tutorial go programming language - Preliminary
Golang iran - tutorial  go programming language - PreliminaryGolang iran - tutorial  go programming language - Preliminary
Golang iran - tutorial go programming language - Preliminary
go-lang
 
Building a Tagless Final DSL for WebGL
Building a Tagless Final DSL for WebGLBuilding a Tagless Final DSL for WebGL
Building a Tagless Final DSL for WebGL
Luka Jacobowitz
 
ĐŸŃ€ĐŸ Đ°ŃĐžĐœŃ…Ń€ĐŸĐœĐœĐŸŃŃ‚ŃŒ / МаĐșŃĐžĐŒ Đ©Đ”ĐżĐ”Đ»ĐžĐœ / Web Developer Wargaming
ĐŸŃ€ĐŸ Đ°ŃĐžĐœŃ…Ń€ĐŸĐœĐœĐŸŃŃ‚ŃŒ / МаĐșŃĐžĐŒ Đ©Đ”ĐżĐ”Đ»ĐžĐœ / Web Developer WargamingĐŸŃ€ĐŸ Đ°ŃĐžĐœŃ…Ń€ĐŸĐœĐœĐŸŃŃ‚ŃŒ / МаĐșŃĐžĐŒ Đ©Đ”ĐżĐ”Đ»ĐžĐœ / Web Developer Wargaming
ĐŸŃ€ĐŸ Đ°ŃĐžĐœŃ…Ń€ĐŸĐœĐœĐŸŃŃ‚ŃŒ / МаĐșŃĐžĐŒ Đ©Đ”ĐżĐ”Đ»ĐžĐœ / Web Developer Wargaming
Python Meetup
 
T3chFest 2016 - The polyglot programmer
T3chFest 2016 - The polyglot programmerT3chFest 2016 - The polyglot programmer
T3chFest 2016 - The polyglot programmer
David Muñoz Díaz
 
Introduction to Go programming language
Introduction to Go programming languageIntroduction to Go programming language
Introduction to Go programming language
Slawomir Dorzak
 
Python
PythonPython
Python
Wei-Bo Chen
 
A CTF Hackers Toolbox
A CTF Hackers ToolboxA CTF Hackers Toolbox
A CTF Hackers Toolbox
Stefan
 
GUL UC3M - Introduction to functional programming
GUL UC3M - Introduction to functional programmingGUL UC3M - Introduction to functional programming
GUL UC3M - Introduction to functional programming
David Muñoz Díaz
 
Writing a compiler in go
Writing a compiler in goWriting a compiler in go
Writing a compiler in go
Yusuke Kita
 

What's hot (20)

Rust vs C++
Rust vs C++Rust vs C++
Rust vs C++
 
Initial Java Core Concept
Initial Java Core ConceptInitial Java Core Concept
Initial Java Core Concept
 
Scalaz By Example (An IO Taster) -- PDXScala Meetup Jan 2014
Scalaz By Example (An IO Taster) -- PDXScala Meetup Jan 2014Scalaz By Example (An IO Taster) -- PDXScala Meetup Jan 2014
Scalaz By Example (An IO Taster) -- PDXScala Meetup Jan 2014
 
Go Lang Tutorial
Go Lang TutorialGo Lang Tutorial
Go Lang Tutorial
 
Go. Why it goes
Go. Why it goesGo. Why it goes
Go. Why it goes
 
DConf 2016: Keynote by Walter Bright
DConf 2016: Keynote by Walter Bright DConf 2016: Keynote by Walter Bright
DConf 2016: Keynote by Walter Bright
 
Let's talks about string operations in C++17
Let's talks about string operations in C++17Let's talks about string operations in C++17
Let's talks about string operations in C++17
 
C sharp 8.0 new features
C sharp 8.0 new featuresC sharp 8.0 new features
C sharp 8.0 new features
 
Empty Base Class Optimisation, [[no_unique_address]] and other C++20 Attributes
Empty Base Class Optimisation, [[no_unique_address]] and other C++20 AttributesEmpty Base Class Optimisation, [[no_unique_address]] and other C++20 Attributes
Empty Base Class Optimisation, [[no_unique_address]] and other C++20 Attributes
 
The best language in the world
The best language in the worldThe best language in the world
The best language in the world
 
The best of AltJava is Xtend
The best of AltJava is XtendThe best of AltJava is Xtend
The best of AltJava is Xtend
 
Golang iran - tutorial go programming language - Preliminary
Golang iran - tutorial  go programming language - PreliminaryGolang iran - tutorial  go programming language - Preliminary
Golang iran - tutorial go programming language - Preliminary
 
Building a Tagless Final DSL for WebGL
Building a Tagless Final DSL for WebGLBuilding a Tagless Final DSL for WebGL
Building a Tagless Final DSL for WebGL
 
ĐŸŃ€ĐŸ Đ°ŃĐžĐœŃ…Ń€ĐŸĐœĐœĐŸŃŃ‚ŃŒ / МаĐșŃĐžĐŒ Đ©Đ”ĐżĐ”Đ»ĐžĐœ / Web Developer Wargaming
ĐŸŃ€ĐŸ Đ°ŃĐžĐœŃ…Ń€ĐŸĐœĐœĐŸŃŃ‚ŃŒ / МаĐșŃĐžĐŒ Đ©Đ”ĐżĐ”Đ»ĐžĐœ / Web Developer WargamingĐŸŃ€ĐŸ Đ°ŃĐžĐœŃ…Ń€ĐŸĐœĐœĐŸŃŃ‚ŃŒ / МаĐșŃĐžĐŒ Đ©Đ”ĐżĐ”Đ»ĐžĐœ / Web Developer Wargaming
ĐŸŃ€ĐŸ Đ°ŃĐžĐœŃ…Ń€ĐŸĐœĐœĐŸŃŃ‚ŃŒ / МаĐșŃĐžĐŒ Đ©Đ”ĐżĐ”Đ»ĐžĐœ / Web Developer Wargaming
 
T3chFest 2016 - The polyglot programmer
T3chFest 2016 - The polyglot programmerT3chFest 2016 - The polyglot programmer
T3chFest 2016 - The polyglot programmer
 
Introduction to Go programming language
Introduction to Go programming languageIntroduction to Go programming language
Introduction to Go programming language
 
Python
PythonPython
Python
 
A CTF Hackers Toolbox
A CTF Hackers ToolboxA CTF Hackers Toolbox
A CTF Hackers Toolbox
 
GUL UC3M - Introduction to functional programming
GUL UC3M - Introduction to functional programmingGUL UC3M - Introduction to functional programming
GUL UC3M - Introduction to functional programming
 
Writing a compiler in go
Writing a compiler in goWriting a compiler in go
Writing a compiler in go
 

Similar to GHCi: More Awesome Than You Thought

Haskell
HaskellHaskell
Haskell
Roberto Casadei
 
Assignment 1 MapReduce With Hadoop
Assignment 1  MapReduce With HadoopAssignment 1  MapReduce With Hadoop
Assignment 1 MapReduce With Hadoop
Allison Thompson
 
C++ development within OOo
C++ development within OOoC++ development within OOo
C++ development within OOo
Alexandro Colorado
 
Extend Redis with Modules
Extend Redis with ModulesExtend Redis with Modules
Extend Redis with Modules
Itamar Haber
 
DevOps(4) : Ansible(2) - (MOSG)
DevOps(4) : Ansible(2) - (MOSG)DevOps(4) : Ansible(2) - (MOSG)
DevOps(4) : Ansible(2) - (MOSG)
Soshi Nemoto
 
Natural Language Processing with CNTK and Apache Spark with Ali Zaidi
Natural Language Processing with CNTK and Apache Spark with Ali ZaidiNatural Language Processing with CNTK and Apache Spark with Ali Zaidi
Natural Language Processing with CNTK and Apache Spark with Ali Zaidi
Databricks
 
Kotlin DSLs
Kotlin DSLsKotlin DSLs
Kotlin DSLs
Stefan Scheidt
 
MobileConf 2021 Slides: Let's build macOS CLI Utilities using Swift
MobileConf 2021 Slides:  Let's build macOS CLI Utilities using SwiftMobileConf 2021 Slides:  Let's build macOS CLI Utilities using Swift
MobileConf 2021 Slides: Let's build macOS CLI Utilities using Swift
Diego Freniche Brito
 
[Defcon24] Introduction to the Witchcraft Compiler Collection
[Defcon24] Introduction to the Witchcraft Compiler Collection[Defcon24] Introduction to the Witchcraft Compiler Collection
[Defcon24] Introduction to the Witchcraft Compiler Collection
Moabi.com
 
Odsc workshop - Distributed Tensorflow on Hops
Odsc workshop - Distributed Tensorflow on HopsOdsc workshop - Distributed Tensorflow on Hops
Odsc workshop - Distributed Tensorflow on Hops
Jim Dowling
 
Introduction-to-C-Part-1.pdf
Introduction-to-C-Part-1.pdfIntroduction-to-C-Part-1.pdf
Introduction-to-C-Part-1.pdf
AnassElHousni
 
The Ring programming language version 1.5.4 book - Part 180 of 185
The Ring programming language version 1.5.4 book - Part 180 of 185The Ring programming language version 1.5.4 book - Part 180 of 185
The Ring programming language version 1.5.4 book - Part 180 of 185
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.2 book - Part 176 of 181
The Ring programming language version 1.5.2 book - Part 176 of 181The Ring programming language version 1.5.2 book - Part 176 of 181
The Ring programming language version 1.5.2 book - Part 176 of 181
Mahmoud Samir Fayed
 
Fuzzing: The New Unit Testing
Fuzzing: The New Unit TestingFuzzing: The New Unit Testing
Fuzzing: The New Unit Testing
Dmitry Vyukov
 
The Ring programming language version 1.8 book - Part 95 of 202
The Ring programming language version 1.8 book - Part 95 of 202The Ring programming language version 1.8 book - Part 95 of 202
The Ring programming language version 1.8 book - Part 95 of 202
Mahmoud Samir Fayed
 
Introduction to Flutter - truly crossplatform, amazingly fast
Introduction to Flutter - truly crossplatform, amazingly fastIntroduction to Flutter - truly crossplatform, amazingly fast
Introduction to Flutter - truly crossplatform, amazingly fast
Bartosz Kosarzycki
 
PowerCLI in the Enterprise Breaking the Magicians Code original
PowerCLI in the Enterprise Breaking the Magicians Code   originalPowerCLI in the Enterprise Breaking the Magicians Code   original
PowerCLI in the Enterprise Breaking the Magicians Code originaljonathanmedd
 
C++Basics2022.pptx
C++Basics2022.pptxC++Basics2022.pptx
C++Basics2022.pptx
Danielle780357
 
Haxe for Flash Platform developer
Haxe for Flash Platform developerHaxe for Flash Platform developer
Haxe for Flash Platform developer
matterhaxe
 

Similar to GHCi: More Awesome Than You Thought (20)

Haskell
HaskellHaskell
Haskell
 
Assignment 1 MapReduce With Hadoop
Assignment 1  MapReduce With HadoopAssignment 1  MapReduce With Hadoop
Assignment 1 MapReduce With Hadoop
 
C++ development within OOo
C++ development within OOoC++ development within OOo
C++ development within OOo
 
Extend Redis with Modules
Extend Redis with ModulesExtend Redis with Modules
Extend Redis with Modules
 
C++ Boot Camp Part 2
C++ Boot Camp Part 2C++ Boot Camp Part 2
C++ Boot Camp Part 2
 
DevOps(4) : Ansible(2) - (MOSG)
DevOps(4) : Ansible(2) - (MOSG)DevOps(4) : Ansible(2) - (MOSG)
DevOps(4) : Ansible(2) - (MOSG)
 
Natural Language Processing with CNTK and Apache Spark with Ali Zaidi
Natural Language Processing with CNTK and Apache Spark with Ali ZaidiNatural Language Processing with CNTK and Apache Spark with Ali Zaidi
Natural Language Processing with CNTK and Apache Spark with Ali Zaidi
 
Kotlin DSLs
Kotlin DSLsKotlin DSLs
Kotlin DSLs
 
MobileConf 2021 Slides: Let's build macOS CLI Utilities using Swift
MobileConf 2021 Slides:  Let's build macOS CLI Utilities using SwiftMobileConf 2021 Slides:  Let's build macOS CLI Utilities using Swift
MobileConf 2021 Slides: Let's build macOS CLI Utilities using Swift
 
[Defcon24] Introduction to the Witchcraft Compiler Collection
[Defcon24] Introduction to the Witchcraft Compiler Collection[Defcon24] Introduction to the Witchcraft Compiler Collection
[Defcon24] Introduction to the Witchcraft Compiler Collection
 
Odsc workshop - Distributed Tensorflow on Hops
Odsc workshop - Distributed Tensorflow on HopsOdsc workshop - Distributed Tensorflow on Hops
Odsc workshop - Distributed Tensorflow on Hops
 
Introduction-to-C-Part-1.pdf
Introduction-to-C-Part-1.pdfIntroduction-to-C-Part-1.pdf
Introduction-to-C-Part-1.pdf
 
The Ring programming language version 1.5.4 book - Part 180 of 185
The Ring programming language version 1.5.4 book - Part 180 of 185The Ring programming language version 1.5.4 book - Part 180 of 185
The Ring programming language version 1.5.4 book - Part 180 of 185
 
The Ring programming language version 1.5.2 book - Part 176 of 181
The Ring programming language version 1.5.2 book - Part 176 of 181The Ring programming language version 1.5.2 book - Part 176 of 181
The Ring programming language version 1.5.2 book - Part 176 of 181
 
Fuzzing: The New Unit Testing
Fuzzing: The New Unit TestingFuzzing: The New Unit Testing
Fuzzing: The New Unit Testing
 
The Ring programming language version 1.8 book - Part 95 of 202
The Ring programming language version 1.8 book - Part 95 of 202The Ring programming language version 1.8 book - Part 95 of 202
The Ring programming language version 1.8 book - Part 95 of 202
 
Introduction to Flutter - truly crossplatform, amazingly fast
Introduction to Flutter - truly crossplatform, amazingly fastIntroduction to Flutter - truly crossplatform, amazingly fast
Introduction to Flutter - truly crossplatform, amazingly fast
 
PowerCLI in the Enterprise Breaking the Magicians Code original
PowerCLI in the Enterprise Breaking the Magicians Code   originalPowerCLI in the Enterprise Breaking the Magicians Code   original
PowerCLI in the Enterprise Breaking the Magicians Code original
 
C++Basics2022.pptx
C++Basics2022.pptxC++Basics2022.pptx
C++Basics2022.pptx
 
Haxe for Flash Platform developer
Haxe for Flash Platform developerHaxe for Flash Platform developer
Haxe for Flash Platform developer
 

More from Richard Minerich

How we use functional programming to find the bad guys @ Build Stuff LT and U...
How we use functional programming to find the bad guys @ Build Stuff LT and U...How we use functional programming to find the bad guys @ Build Stuff LT and U...
How we use functional programming to find the bad guys @ Build Stuff LT and U...
Richard Minerich
 
Functional Ideas for a Cloudy Future
Functional Ideas for a Cloudy FutureFunctional Ideas for a Cloudy Future
Functional Ideas for a Cloudy Future
Richard Minerich
 
F# and the DLR
F# and the DLRF# and the DLR
F# and the DLR
Richard Minerich
 
Getting the MVVM Kicked Out of Your F#'n Monads
Getting the MVVM Kicked Out of Your F#'n MonadsGetting the MVVM Kicked Out of Your F#'n Monads
Getting the MVVM Kicked Out of Your F#'n MonadsRichard Minerich
 
How you can get started with F# today
How you can get started with F# todayHow you can get started with F# today
How you can get started with F# todayRichard Minerich
 
F# in the Classroom and the Lab
F# in the Classroom and the LabF# in the Classroom and the Lab
F# in the Classroom and the Lab
Richard Minerich
 

More from Richard Minerich (7)

How we use functional programming to find the bad guys @ Build Stuff LT and U...
How we use functional programming to find the bad guys @ Build Stuff LT and U...How we use functional programming to find the bad guys @ Build Stuff LT and U...
How we use functional programming to find the bad guys @ Build Stuff LT and U...
 
Functional Ideas for a Cloudy Future
Functional Ideas for a Cloudy FutureFunctional Ideas for a Cloudy Future
Functional Ideas for a Cloudy Future
 
F# and the DLR
F# and the DLRF# and the DLR
F# and the DLR
 
Fun and Games in F#
Fun and Games in F#Fun and Games in F#
Fun and Games in F#
 
Getting the MVVM Kicked Out of Your F#'n Monads
Getting the MVVM Kicked Out of Your F#'n MonadsGetting the MVVM Kicked Out of Your F#'n Monads
Getting the MVVM Kicked Out of Your F#'n Monads
 
How you can get started with F# today
How you can get started with F# todayHow you can get started with F# today
How you can get started with F# today
 
F# in the Classroom and the Lab
F# in the Classroom and the LabF# in the Classroom and the Lab
F# in the Classroom and the Lab
 

Recently uploaded

From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
g2nightmarescribd
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 

Recently uploaded (20)

From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 

GHCi: More Awesome Than You Thought

  • 1. -- GHCi -- More Awesome Than You (I?) Thought Richard Minerich Senior Researcher at Bayard Rock @Rickasaurus
  • 2. Noob Answers for Noob Questions How do I allow multi-line definitions? Wrap it in “:{ 
 :}” or “:set +m” Why doesn’t it show the type of my result? “:set +t” will enable type info. Why won’t my Haskell code execute in GHCi? GHCi uses the monad “let” syntax. How do I specify the type of something? Follow it with “:: type” (e.g x = 5 :: Int)
  • 3. Setup for this talk Sublime Text 2 with - SublimeHaskell - SublimeREPL (head) - Tabs to Spaces on Haskell Platform (2012.4.0.0) with aeson, haskell-src-exts, haddock, ghc-mod, stylish-haskell, haskell-docs
  • 4. SublimeREPL SublimeREPL (as of last week) will now: - Intelligently remove extra whitespace in front of nested functions - Prepends “let “ to functions sent to the REPL and indents the remainder (as needed) - Automatically wraps multi-line functions with the new block syntax :{ .. :}
  • 5. Haskell for Scripting -- script.hs -- #!/usr/bin/env runhaskell main = putStrLn “Hello, or something
” On Windows: runhaskell script.hs On Posix: ./script.hs
  • 6. GHCi Custom Configs Search Paths: :set +t :def hoogle str -> return $ ":! hoogle --count=15 "" ++ str ++ """ Tons of useful macros at the wiki: http://www.haskell.org/haskellwiki/GHC/GHCi ./.ghci $HOME/.ghc/ghci.conf appdata/ghc/ghci.conf $HOME/.ghci
  • 7. Play with Language Flags {-# LANGUAGE NoMonomorphismRestriction #-} Vs. :set –XNoMonomorphismRestriction Vs. (in latest Haskell Platform) :seti –XNoMonomorphismRestriction
  • 8. Loading Modules By default module Dir.Module is Dir/Module.hs :load Dir.Module Load compiled if exists :load *Dir.Module Load interpreted forced :reload Reloads target set :show modules List loaded modules
  • 9. Compiled vs. Interpreted Compiled Interpreted ~10x Faster Execution ~2x Faster Load Dependencies must be compiled Dependencies compiled or interpreted Only exports available Exports or full scope “:! ghc –c Module.hs” Noop
  • 10. Controlling GHCi Scope :show imports Shows what’s in scope :module – Dir1.Module1 
 Remove “./Dir1/Module1.hs” from scope :module + Dir1.Module1 *Dir2.Module2 
 Open exports from “./Dir1/Module1.hs” Open full scope from “./Dir2/Module2.hs” Standard import syntax applies as well
  • 11. Your Eyes and Ears :browse Module - Shows a module’s exports :browse *Module – Shows full Module scope :show bindings – List bound variables with type :type <expr> - Type information for an expr :info <name> - Extended information :print <id> - Print without forced evaluation :force <id> - Print with forced evaluation
  • 12. GHCi Funny Business GHCi is a monad, monad syntax applies (kind of) Bindings go away after “:load” or “:reload” Type defaults (are strange) It’s thunks all the way down “print” vs “:print” vs “:sprint” vs “:force”
  • 13. Things to know about Debugging All the standard stuff: - Breakpoints, Break on Exception, Stepping And some fancy stuff: - Time Travel, Subexpression Breakpoints But, some oddities (coming from other langs): - Scope, Execution Ordering, :Print Breakpoints
  • 14. Review: Debugging Basics :set stop :list :break [<id>] or [<module?> <line?> <col?>] :show breaks :delete <breakpoint_id|*> :step <expr?> / :steplocal / :stepmodule :abandon / :continue :print <id> / :force <id>
  • 15. Review: Time Travel Wizardry :trace <expr> :hist <num?> :back / :forward :show context :set –fbreak-on-exception :set –fbreak-on-error _result / _exception
  • 16. How the heck do I trace? Remember, Haskell is lazy. So be thoughtful: - Break inside, near the end - Leverage assertions with error (import Control.Exception (assert)) - Give BangPatterns a go - Debug from a secondary .hs file - Implement conditional breakpoints
  • 17. That was just the tip of the iceburg, see the Docs and Wiki for MUCH more information.

Editor's Notes

  1. Comic Sans and Powerpoint!A beginner talk, from the perspective of someone trying to learn haskellI’m going to talk a lot about the things that I found difficult, and some of the tricks I’ve discovered. Please raise your hand if you have a better workaround and we’ll bring you the mic
  2. Multiline mode seems like the best if you don’t have a fancy IDE, but I’d rather just highlight and goThe lack of type info bugged me a lot at first. Most ML languages show type and result by default.The different syntax for GHCi was extremely frustrating when I was starting out.I found this out on stackoverflow of all places. It doesn’t seem to be in the docs anywhere.
  3. Fixed up
  4. I added this because I hated not being able to just highlight and execute things in the REPL (a standard feature of most ML languages)Started trying to write haskell with nested functions to execute in the replThen added the wrapping syntax so I didn’t need to leave on the multi-line syntax (it’s annoying)Finally, it occurred to me that I could simply prepend let and indent You can disable any of these features independently*show it*Future: Type sigs, more than one function at a time
  5. Haskell scripts seem great for mutli-platform targets.
  6. Because haskell is so configurable, it’s probably best to keep a separate .ghci per projectput the :set +m and :set +t to be auto run hereWe could do a whole talk on pimping your GHCi, but for now let’s focus on how to use it, for more examples check out the wiki
  7. Monomorphism Restriction: Cannot overload a function unless you provide an explicit type sigNote that some things can’t be unset, such as this particular flag
  8. Modules can be loaded in either compiled or interpreted mode. Compiled modules can only depend on other compiled, so for now we’ll be loaded everything interpreted.
  9. Moral of the story, if you’re new and just fiddling around you should probably just stick with interpreted
  10. Modules can be loaded in either compiled or interpreted mode. Compiled modules can only depend on other compiled, so for now we’ll be loaded everything interpreted.
  11. Info usually does the right thing for what you’re looking atPrint will show you the types of the unevaluated thunksForce will show you the result
  12. 1) Monads, but with type declarations and lots of special commands?2) Because the bindings will frequently disappear on you, it seems best to work with a temporary file outside of the repl3) You may find yourself needing to use type annotations4) A haskell thing, not ghci, but you may find yourself hitting a breakpoint in the process of debugging (especially recursive functions)5) You can hit breakpoints with the print command or force
  13. Most of the oddities stem from laziness.
  14. With breakpoints you can target just about anywhere, be it the name or a specific character in a fileStep sets implicit breakpoints everywhere, steplocal just within the current scope, and stepmodule just within the current module
  15. fbreak-on-exception will break on any exception fbreak-on-error will break on uncaught exceptions
  16. I’ve found that getting a trace where I want it can be somewhat difficult.