haskell

How do I connect Haskell HDBC to an oracle db on osx

不问归期 提交于 2020-01-14 06:01:48
问题 I was wondering how you are supposed to connect to an oracle db on mac with Haskell HDBC. I tried doing it through ODBC, by running brew install unixobcd and then installing oracle instant client basic and obdc into a directory. Then in Haskell, with HDBC and HDBC-odbc both installed, calling connectODBC with Driver set to the location of libsqora.dylib.12.1 in said directory. It is giving me sot-dba: SqlError {seState = "[\"01000\"]", seNativeError = -1, seErrorMsg = "connectODBC

cabal-install-0.10.2 failed during the building phase

╄→гoц情女王★ 提交于 2020-01-14 05:55:28
问题 I was trying to install haskeline, it's my first time installing using cabal, and here is what I got. What should I do? . sudo cabal install haskeline Password: Config file /Users/arie/.cabal/config not found. Writing default configuration to /Users/arie/.cabal/config Warning: The package list for 'hackage.haskell.org' does not exist. Run 'cabal update' to download it. cabal: There is no package named haskeline . sudo cabal update Downloading the latest package list from hackage.haskell.org

How to use the epoll/kqueue enabled version of GHC/Haskell for network connections?

坚强是说给别人听的谎言 提交于 2020-01-14 04:24:08
问题 There is a lot of old information on the net regarding an epoll/kqueue enabled GHC. For example, the code on the Simple Servers wiki page doesn't compile anymore. Could someone provide a basic example of how to use this feature with a modern GHC version to build, e.g. a TCP server that just responds with "Hello" on connect? 回答1: GHC's IO manager uses epoll/kqueue under the hood without any special programmer effort. Just write the naive threaded program -- that puts each concurrent blocking

Binding the entire output of an ongoing system process to a variable in Haskell

ε祈祈猫儿з 提交于 2020-01-14 04:07:13
问题 The following snippet of code executes a grep command and binds the output to stdout' , stderr' and errCode respectively. main :: IO () main = do let stdin' = "" (errCode, stdout', stderr') <- readProcessWithExitCode "grep" ["search-term" ,"-nr", "/path/to/be/searched"] stdin' putStrLn $ "stdout: " ++ stdout' putStrLn $ "stderr: " ++ stderr' putStrLn $ "errCode: " ++ show errCode The problem is that stdout' only captures the first result of the search. I think this is because grep is

Mapping a function over two input lists

喜夏-厌秋 提交于 2020-01-14 03:51:09
问题 I have a function that I want to test with several sets of inputs. Let's say the function is f :: a -> b -> c Now I have two lists of inputs: inputA :: [a] inputB :: [[b]] For inputA !! i , I want evaluate f $ input !! i for each element of the list at inputB !! i . I know I need several applications of map to do this, but I am having difficulty wrapping my head around a solution. My most recent attempt is map f inputA <$> inputB which gives the following error: Couldn't match expected type

Is there a pretty printing (or showing) abstraction in Haskell?

北慕城南 提交于 2020-01-13 19:55:11
问题 Is there no standard way to print out values for end-user consumption? Show is clearly more of a debugging convenience than something that would work for this purpose, given the conventions around its use and the constraint that read (show x) == x . For example, isn't there at least a simple package like class (Show a) => PShow a where pshow :: a -> String pshow = show pprint :: (PShow a) => a -> IO () pprint = putStrLn . pshow where instances do something like instance PShow MyType where

Haskell - Having trouble understanding a small bit of code

帅比萌擦擦* 提交于 2020-01-13 19:54:26
问题 I am doing a school task where I am given a small bit of sample code which I can use later. I understand 90% of this code but there is one little line/function that I for the life of me can't figure out what it does (I am very new to Haskell btw). Sample code: data Profile = Profile {matrix::[[(Char,Int)]], moleType::SeqType, nrOfSeqs::Int, nm::String} deriving (Show) nucleotides = "ACGT" aminoacids = sort "ARNDCEQGHILKMFPSTWYVX" makeProfileMatrix :: [MolSeq] -> [[(Char, Int)]]

Mixing Threepenny-Gui and StateT

无人久伴 提交于 2020-01-13 19:29:31
问题 I have a question on the interaction of Threepenny-Gui with StateT. Consider this toy program that, every time the button is clicked, adds a "Hi" item in the list: import Control.Monad import Control.Monad.State import qualified Graphics.UI.Threepenny as UI import Graphics.UI.Threepenny.Core hiding (get) main :: IO () main = startGUI defaultConfig setup setup :: Window -> UI () setup w = void $ do return w # set title "Ciao" buttonAndList <- mkButtonAndList getBody w #+ map element

hubris fails to install with: Missing C libraries: ruby, ruby, ruby

人走茶凉 提交于 2020-01-13 18:59:11
问题 I am desperately trying to install Hubris but the installation fails whenever I run "cabal install". Link to Hurbis: https://github.com/mwotton/Hubris/tree/master/Haskell Link to the Cabal file: https://github.com/mwotton/Hubris/blob/master/Haskell/hubris.cabal The cabal command that fails is: cabal install --extra-include-dirs=/usr/include/ruby-1.9.1/x86_64-linux --extra-include-dirs=/usr/include/ruby-1.9.1 --extra-lib-dirs=/usr/lib --user --enable-shared --with-ghc=/usr/local/bin/ghc The

How to make specialized type classes for certain types, default implementation for the rest of types

荒凉一梦 提交于 2020-01-13 17:57:19
问题 I would like to have a type class of types that can possibly casted to other types when possible. class Castable a b where cast :: a -> Maybe b cast _ = Nothing -- default implementation Now the class would be implemented for some types and for all the others I would like to have default implementation. How one can do that? 回答1: It's not necessarily a safe or Haskell-y thing to do, but it is certainly possible, using OverlappingInstances First, enable them: {-# LANGUAGE MultiParamTypeClasses