Skip to main content

Home/ Haskell/ Group items tagged IDE

Rss Feed Group items tagged

Javier Neira

Leksah - Haskell IDE in Haskell - 0 views

  •  
    Leksah is a Haskell IDE (Integrated Development Environment) written in Haskell based on Gtk+ and gtk2hs. Leksah is a practical tool to support the Haskell development process. It is platform independent and runs on any platform where GTK+, gtk2hs and GHC can be installed. It is currently been tested on Windows and Linux but it should work on the Mac. It works with the Glasgow Haskell Compiler (GHC). Leksah is completely free and distributed under the Gnu Public License 2.0
Javier Neira

jaspervdj - Maybe, null, and boilerplate code - 0 views

  • A first goal they serve is as "unassigned variables". I will not cover that here, instead I will focus on another use: abnormal return values.
  • So, null is some sort of "Not found" error here. But wait - they could have used an Exception here!
  • We see a similar behavior here: when the object is found, we get a Just a, and when it is not found, we get Nothing - comparable to a null pointer.
  • ...5 more annotations...
  • So, while we can get a null back from a function, we should never give it to a function.
  • Now, if you have written a lot of Java code, you know that checking for null is a vital part of the job, and fragments like the one above are pretty common.
  • In Haskell, however, Maybe is also a monad - and monads can be used to prevent common patterns in code - in other words, they assist you in the D.R.Y.-principle2. We can therefore write the above snippet again using do-notation3.
  • getPathMonth :: Map String String -> Maybe MonthgetPathMonth m = do p <- lookup "path" m d <- parseDate p return $ getMonth d
  • he whole "check-for-null-and-short-circuit" behavior is defined by the Maybe monad -
  •  
    getPathMonth :: Map String String -> Maybe Month getPathMonth m = case M.lookup "path" m of Nothing -> Nothing (Just p) -> case parseDate p of Nothing -> Nothing (Just d) -> Just (getMonth d) getPathMonth :: Map String String -> Maybe Month getPathMonth m = do p <- parseDate p return $ getMonth d
1 - 2 of 2
Showing 20 items per page