Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting basic Scheme functions to Haskell equivalents

I am trying to convert scheme code to Haskell code.

For that, I want know how to use scheme's

  1. map
  2. lambda
  3. return port from file path
  4. read-line from port
  5. append to list
  6. regexp-match
  7. GUI

in Haskell

could somebody tell me how to do this in haskell? thanks

like image 343
kim taeyun Avatar asked Sep 06 '25 18:09

kim taeyun


1 Answers

Essentially you need to learn Haskell, the language, and its library ecosystem. To find libraries and functions, start by learning the Prelude, since many things are defined there. Then move on to Hackage, where you have thousands of libraries to pick from.

Specifically, most of what you need can be found in the Prelude, and via Hoogle.

  1. map is defined.

  2. "lambda" is the syntax: \x -> ... e ...

  3. "return port from file path": try openFile

  4. "read-line from port", try hGetLine

  5. "append to list", try ++

  6. "regexp-match", use one of the fine regex libraries from Hackage.

  7. "GUI", pick one of gtk2hs or wxHaskell.

like image 198
Don Stewart Avatar answered Sep 09 '25 07:09

Don Stewart