Haskell Language

Web Name: Haskell Language

WebSite: http://www.haskell.org

ID:25299

Keywords:

Haskell,Language,

Description:

Escape from the ivory tower: The Haskell journey, by Simon Peyton-Jones Haskell taketh away: limiting side effects for parallel programming, by Ryan Newton Haskell is Not For Production and Other Tales, by Katie Miller Your First Web Application with Spock, by Oskar Wickström Statically typed Every expression in Haskell has a type which is determined at compile time. All the types composed together by function application have to match up. If they don't, the program will be rejected by the compiler. Types become not only a form of guarantee, but a language for expressing the construction of programs. Click to expand All Haskell values have a type: char = 'a' :: Charint = 123 :: Intfun = isDigit :: Char - Bool You have to pass the right type of values to functions, or the compiler will reject the program: Type error isDigit 1 You can decode bytes into text: bytes = Crypto.Hash.SHA1.hash "hello" :: ByteStringtext = decodeUtf8 bytes :: Text But you cannot decode Text, which is already a vector of Unicode points: Type error doubleDecode = decodeUtf8 (decodeUtf8 bytes) Purely functional Every function in Haskell is a function in the mathematical sense (i.e., pure ). Even side-effecting IO operations are but a description of what to do, produced by pure code. There are no statements or instructions, only expressions which cannot mutate variables (local or global) nor access state like time or random numbers. Click to expand The following function takes an integer and returns an integer. By the type it cannot do any side-effects whatsoever, it cannot mutate any of its arguments. square :: Int - Intsquare x = x * x The following string concatenation is okay: "Hello: " ++ "World!" The following string concatenation is a type error: Type error "Name: " ++ getLine Because getLine has type IO String and not String, like Name: is. So by the type system you cannot mix and match purity with impurity. Type inference You don't have to explicitly write out every type in a Haskell program. Types will be inferred by unifying every type bidirectionally. However, you can write out types if you choose, or ask the compiler to write them for you for handy documentation. Click to expand This example has a type signature for every binding: main :: IO ()main = do line :: String - getLine print (parseDigit line) where parseDigit :: String - Maybe Int parseDigit ((c :: Char) : _) = if isDigit c then Just (ord c - ord '0') else Nothing But you can just write: main = do line - getLine print (parseDigit line) where parseDigit (c : _) = if isDigit c then Just (ord c - ord '0') else Nothing You can also use inference to avoid wasting time explaining what you want: do ss - decode "[\"Hello!\",\"World!\"]" is - decode "[1,2,3]" return (zipWith (\s i - s ++ " " ++ show (i + 5)) ss is) = Just ["Hello! 6","World! 7"] Types give a parser specification for free, the following input is not accepted: do ss - decode "[1,2,3]" is - decode "[null,null,null]" return (zipWith (\s i - s ++ " " ++ show (i + 5)) ss is) = Nothing Concurrent Haskell lends itself well to concurrent programming due to its explicit handling of effects. Its flagship compiler, GHC, comes with a high-performance parallel garbage collector and light-weight concurrency library containing a number of useful concurrency primitives and abstractions. Click to expand Easily launch threads and communicate with the standard library: main = do done - newEmptyMVar forkIO (do putStrLn "I'm one thread!" putMVar done "Done!") second - forkIO (do threadDelay 100000 putStrLn "I'm another thread!") killThread second msg - takeMVar done putStrLn msg Use an asynchronous API for threads: do a1 - async (getURL url1) a2 - async (getURL url2) page1 - wait a1 page2 - wait a2 ... Atomic threading with software transactional memory: transfer :: Account - Account - Int - IO ()transfer from to amount = atomically (do deposit to amount withdraw from amount) Atomic transactions must be repeatable, so arbitrary IO is disabled in the type system: Type error main = atomically (putStrLn "Hello!") Lazy Functions don't evaluate their arguments. This means that programs can compose together very well, with the ability to write control constructs (such as if/else) just by writing normal functions. The purity of Haskell code makes it easy to fuse chains of functions together, allowing for performance benefits. Click to expand Define control structures easily: when p m = if p then m else return ()main = do args - getArgs when (null args) (putStrLn "No args specified!") If you notice a repeated expression pattern, like if c then t else False you can give this a name, like and c t = if c then t else False and then use it with the same effect as the orginal expression. Get code re-use by composing lazy functions. It's quite natural to express the any function by reusing the map and or functions: any :: (a - Bool) - [a] - Boolany p = or . map p Reuse the recursion patterns in map, filter, foldr, etc. Packages Open source contribution to Haskell is very active with a wide range of packages available on the public package servers. Click to expand There are 6,954 packages freely available. Here is a sample of the most common ones: DataDog provides powerful, customizable 24/7 metrics and monitoring integration for all of Haskell.org, and complains loudly for us when things go wrong. Fastly's Next Generation CDN provides low latency access for all of Haskell.org's downloads and highest traffic services, including the primary Hackage server, Haskell Platform downloads, and more. Packet provides compute, storage, and networking resources, powering almost all of Haskell.org in several regions around the world. Galois provides infrastructure, funds, administrative resources and has historically hosted critical Haskell.org infrastructure, as well as helping the Haskell community at large with their work. DreamHost has teamed up to provide Haskell.org with redundant, scalable object-storage through their Dream Objects service. Webmon provides monitoring and escalation for core haskell.org infrastructure. Psst! Looking for the wiki? This is the new Haskell home page! The wiki has moved to wiki.haskell.org. Got changes to contribute to the site? Fork or comment on Github Proudly hosted by

TAGS:Haskell Language 

<<< Thank you for your visit >>>

Websites to related :
Bossip | Entertainment News Cel

  More Stories From Bossip Chance The Rapper Capes For Kanye As President; Gets Dragged... We've joined the BHM Digital family of websites and have up

Funny Pictures, Greetings, Wall

  Valentine's Day(Valentine's Day 2018)February 14th is celebrated as the day of love and romance all over the world in the form of Valentine's Day. Sen

Home page for Frances Brodigan (

  Hi There! This is a place to display something about myself and all my varied interest. Please feel free to poke around and check things out. I'm sure

Shoestring Trio

  Sorry, Bandcamp no longer supports the version of Internet Explorer that you're using (7.0). Please upgrade your browser to the latest version and try

Turun yliopisto

  Turun yliopisto Turun yliopisto on 25 000 opiskelijan ja työntekijän aktiivinen akateeminen yhteisö. Tutkimme, opetamme ja teemme työtä paremman

AEP | School of Applied Enginee

  Learn Physics. Speak Engineering. Apply Give News VIEW OUR WORLD-CLASS FACILITIES MEET OUR EXCEPTIONAL FACULTY REVIEW OUR GROUND-BREAKING RESEARC

Homepage | Food Standards Agency

  Food we can trustOur job is to use our expertise and influence so that people can trust that the food they buy and eat is safe and what it says it is.

City of St. Peters, Missouri |

  Welcome to St. Peters, Missouri Nationally recognized as a great place to live, the City of St. Peters offers affordable, quality living with top-notc

Pet Friendly Hotels: Find a Pet

  We provide the single largest inventory of pet friendly hotels, motels and accommodations in the United States. Pet Friendly Hotels works directly wit

Apartments for Rent and Rental L

  Price: $2,250Property Type: ApartmentBedrooms: 3.0Bathrooms: 1.0Pets: Case By CaseApartment AmenitiesLow FEENew Stove/Refrigerato...Married couple loo

ads

Hot Websites