Haskell N/W ?? Rashmesh Radhakrishnan

Slides:



Advertisements
Similar presentations
Reading and Writing Text Files Svetlin Nakov Telerik Corporation
Advertisements

Chapter 16 Communicating With the Outside World. Motivation  In Chapter 3 we learned how to do basic IO, but it was fairly limited.  In this chapter.
Grab Bag of Interesting Stuff. Topics Higher kinded types Files and handles IOError Arrays.
Chapter 3 Simple Graphics. Side Effects and Haskell  All the programs we have seen so far have no “side-effects.” That is, programs are executed only.
Advanced Programming Handout 12 Higher-Order Types (SOE Chapter 18)
1 Nonblocking I/O Nonblocking reads and writes Buffers enabling overlapped nonblocking I/O Nonblocking connect.
Cse536 Functional Programming 1 6/30/2015 Lecture #16, Nov. 29, 2004 Todays Topics – Files, Channels, and Handles –IO exception handling –First Class Channels.
Leica DISTO™ D810 touch supported devices. Leica DISTO™ D810 touch - supported iOS devices Leica DISTO™ D810 touch Leica DISTO™ sketch.
0 PROGRAMMING IN HASKELL Chapter 9 - Interactive Programs.
Lab 6: Introduction to Sockets (Web Programming – Part 1) Reference: Head First Java (2 nd Edition) by Kathy Sierra & Bert Bates.
Haskell Chapter 8. Input and Output  What are I/O actions?  How do I/O actions enable us to do I/O?  When are I/O actions actually performed?
Sockets Sockets A socket is an object that encapsulates a TCP/IP connection There is a socket on both ends of a connection, the client side and the server.
Agate: an Agda -to- Haskell compiler AIST / CVS Hiroyuki Ozaki (joint work with Makoto Takeyama)
0 Odds and Ends in Haskell: Folding, I/O, and Functors Adapted from material by Miran Lipovaca.
Arvind Computer Science and Artificial Intelligence Laboratory M.I.T. L13-1 October 26, 2006http:// Monadic Programming October.
Lee CSCE 314 TAMU 1 CSCE 314 Programming Languages Interactive Programs: I/O and Monads Dr. Hyunyoung Lee.
Monads. foo1 Method to print a string, then return its length: scala> def foo1(bar: String) = { | println(bar) | bar.size | } foo1: (bar: String)Int scala>
Grab Bag of Interesting Stuff. Higher Order types Type constructors are higher order since they take types as input and return types as output. Some type.
FUNCTIONAL PROGRAMING AT WORK - HASKELL AND DOMAIN SPECIFIC LANGUAGES Dr. John Peterson Western State Colorado University.
Haskell Chapter 9. More Input and More Output  Files and Streams  Transforming Input  Not covered  brackets  command-line arguments  bytestrings.
教育卡(电子卡) 身份信息认证指导 (学生). 身份信息认证渠道 教育卡管理中心为学生提供了 “ 教育卡官方网站 ” 和 “ 教育人人通客户端 ” 两种认证渠道。 1 教育人人通客户端 2 ●● 您可以在教育卡网站的 “ 人人通客户端 ” 版块下载江苏教育人人通客户端。
24-Jun-16 Haskell Dealing with impurity. Purity Haskell is a “pure” functional programming language Functions have no side effects Input/output is a side.
Locks and Threads and Monads—OOo My ● Stephan Bergmann – StarOffice/OpenOffice.org ● Sun Microsystems.
Hello Educational presentation.
Functional Programming
Haskell Chapter 8.
dr Robert Kowalczyk WMiI UŁ
Theory of Computation Lecture 4: Programs and Computable Functions II
PROGRAMMING IN HASKELL
Haskell Chapter 9.
Haskell programming language.
Beyond HTTP Up to this point we have been dealing with software tools that run on browsers and communicate to a server that generates files that can be.
Higher-Order Functions
Type Topic in here! Created by Educational Technology Network
Installation and exercises
Hire Toyota Innova in Delhi for Outstation Tour
شروط الموصي.
File Input/Output (I/O)
PROGRAMMING IN HASKELL
Tonga Institute of Higher Education
CSE 341 : Programming Languages Section 5 Haskell: Round 3
Haskell Dealing with impurity 30-Nov-18.
Haskell Dealing with impurity 30-Nov-18.
HELLO THERE. THIS IS A TEST SLIDE SLIDE NUMBER 1.

Input and Output.
Ашық сабақ 7 сынып Файлдар мен қапшықтар Сабақтың тақырыбы:
Windows басқару элементтері
Haskell Dealing with impurity 8-Apr-19.
PROGRAMMING IN HASKELL
Grab Bag of Interesting Stuff
Type Topic in here! Created by Educational Technology Network
Programming Languages
Computer Science 312 I/O and Side Effects 1.
Programming Assignment #1
Type Topic in here! Created by Educational Technology Network
Type Topic in here! Created by Educational Technology Network
Module 3 Arithmetic and Geometric Sequences
Type Topic in here! Created by Educational Technology Network
Қош келдіңіздер!.
Haskell Dealing with impurity 29-May-19.
Add Main Topic Here Created by Educational Technology Network
Type Topic in here! Created by Educational Technology Network
Module 3 Arithmetic and Geometric Sequences
Type Topic in here! Created by Educational Technology Network
Type Topic in here! Created by Educational Technology Network
Haskell Dealing with impurity 28-Jun-19.
Monads.
Информатика пән мұғалімі : Аитова Карима.
Presentation transcript:

Haskell N/W ?? Rashmesh Radhakrishnan

Server.hs

module Main( main ) where import Network import System.IO import Control.Concurrent main :: IO () main = withSocketsDo $ --For windows compatibility do theSocket <- listenOn (PortNumber 2049) sequence_ $ repeat $ acceptConnectionAndFork theSocket where acceptConnectionAndFork :: Socket -> IO () acceptConnectionAndFork theSocket = do connection <- accept theSocket let (handle, hostname, portnumber ) = connection putStr ("("++ hostname ++ ":" ++ (show portnumber) ++ "): Open\n" ) forkIO (echoServer connection) return () echoServer :: (Handle, String, PortNumber) -> IO () echoServer (handle, hostname, portnumber ) = do a <- hGetContents handle putStr $ foldr (++) "" $ map (\a -> "(" ++ hostname ++ ":" ++ (show portnumber) ++ "): Changed here " ++ (show a) ++ "\n" ) $ lines a putStr ("("++ hostname ++ ":" ++ (show portnumber) ++ "): Close\n" )

Client.hs

module Main( main ) where import Network import System.IO import Control.Concurrent main :: IO () main = withSocketsDo $ --For windows compatibility do handle <- connectTo "localhost" (PortNumber 2049) input <- getContents sequence_ $ map ( \a -> do hPutStr handle $ a ++ " Hello \n" hFlush handle ) $ lines input hClose handle

Server.hs

Trivial examples

To do list Demonstrate in Haskell and C++: P1: Immutable states P1 : Closures P1: First-class functions P1: Higher-order functions P1: Pure functions P1: Recursions

References N/W example Haskell: http://www.haskell.org/pipermail/haskell/2003-April/011580.html https://hackage.haskell.org/package/HTTP-4000.0.9/docs/Network-TCP.html Learning Elixir: http://learnxinyminutes.com/docs/elixir/ http://elixir-lang.org/getting_started/1.html

Thank you