The standard way to share a Haskell library with other programmers is to create a Cabal package and upload it to http://hackage.haskell.org. I've written a library I wish to share, and
I've successfully created a Cabal package using the guidelines online for creating cabal files. I've built the package and installed it locallyworks fi...
So I recently installed cabal (from the default binary of ArchLinux).
I then tried to upgrade cabal as a user:
cabal upgrade Cabal --user --prefix=$USER
Resolving dependencies...
cabal: fromFlag NoFlag. Use fromFlagOrDefault
What I've already done:
Googled the error message. Turned up the cabal source and little else.
Looked ...
I wrote a little Haskell program to find the area of a triangle, primarily to practice custom types, but it keeps throwing the following error on compile:
areafinder.hs:7:4:
Couldn't match expected type `Triangle' against inferred type `m b'
In a stmt of a 'do' expression: putStr "Base: "
In the expression:
do { putS...
I want to apply a function f to a list of values, however function f might randomly fail (it is in effect making a call out to a service in the cloud).
I thought I'd want to use something like map, but I want to apply the function to all elements in the list and afterwards, I want to know which ones failed and which were successful.
...
Hi! This code compiles fine:
{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies, FlexibleInstances,
UndecidableInstances, FlexibleContexts, EmptyDataDecls, ScopedTypeVariables,
TypeOperators, TypeSynonymInstances, TypeFamilies #-}
class Sel a s b where
type Res a s b :: *
instance Sel a s b where
type Res a s b = (s -> ...
In the example given in http://web.archive.org/web/20080622204226/http://www.cs.vu.nl/boilerplate/
-- Increase salary by percentage
increase :: Float -> Company -> Company
increase k = everywhere (mkT (incS k))
-- "interesting" code for increase
incS :: Float -> Salary -> Salary
incS k (S s) = S (s * (1+k))
how come increase functio...
I'm working fast and furiously on a new Haskell package for compiler writers. I'm going through many minor version numbers daily, and the Haskell packaging system, Cabal, doesn't seem to offer any tools for updating version numbers or for maintaining a change log. (Logs are going into git but that's not visible to anyone using the pack...
I need some help in figuring a compiler error which is really driving me nuts...
I have the following type class:
infixl 7 -->
class Selectable a s b where
type Res a s b :: *
(-->) :: (CNum n) => (Reference s a) -> (n,(a->b),(a->b->a)) -> Res a s b
which I instance twice. First time goes like a charm:
instance Selectable a s b ...
I'm in chapter 8 of Graham Hutton's Programming in Haskell and I'm copying the code and testing it in GHC.
See the slides here: http://www.cis.syr.edu/~sueo/cis352/chapter8.pdf in particular slide 15
The relevant code I've copied so far is:
type Parser a = String -> [(a, String)]
pih_return :: a -> Parser a
pih_return v = \inp -> [(v,...
Does Visual Haskell for Visual Studio 2008/2010 exist? Or what are the alternatives to try it?
EDIT: I've got a lot of alternatives but it seems that there is no Visual Haskell right now.
...
Hello! i'm trying to profile a quicksort code. the code is as follows:
qsort [] = []
qsort (x:xs) = qsort (filter (< x) xs) ++ [x] ++ qsort (filter (>= x) xs)
please help me out!
...
I would like to make a method where I could give it a list of lengths and it would return all combinations of cartesian coordinates up to those lengths. Easier to explain with an example:
cart [2,5]
Prelude> [ [0,0],[0,1],[0,2],[0,3],[0,4],[1,0],[1,1],[1,2],[1,3],[1,4] ]
cart [2,2,2]
Prelude> [ [0,0,0],[0,0,1],[0,1,0],[0,1,1],[1,0,0],[...
I have a merge function which takes time O(log n) to combine two trees into one, and a listToTree function which converts an initial list of elements to singleton trees and repeatedly calls merge on each successive pair of trees until only one tree remains.
Function signatures and relevant implementations are as follows:
merge :: Tree ...
I have to traverse a matrix and say how many "characteristic areas" of each type it has.
A characteristic area is defined as a zone where elements of value n or >n are adjacent.
For example, given the matrix:
0 1 2 2
0 1 1 2
0 3 0 0
There's a single characteristic area of type 1 which is equal to the original matrix:
0 1 2 2
0 1...
I'm working on a dataflow-based optimization library written in Haskell. It now seems likely that the library is going to have to be split into two pieces:
A core piece with minimal build dependencies; call it hoopl-core.
A full piece, call it hoopl, which may have extra dependencies on packages like a prettyprinter, QuickCheck, and s...
Let's consider a data type with many constructors:
data T = Alpha Int | Beta Int | Gamma Int Int | Delta Int
I want to write a function to check if two values are produced with the same constructor:
sameK (Alpha _) (Alpha _) = True
sameK (Beta _) (Beta _) = True
sameK (Gamma _ _) (Gamma _ _) = True
sameK _ _ = False
Maintaining sam...
Possible Duplicate:
What does the exclamation mark mean in a Haskell declaration?
In Alex the generated boilerplate code includes
data AlexPosn = AlexPn !Int -- absolute character offset
!Int -- line number
!Int -- column number
What does the ! in front of the Int indicate?
...
In Haskell, there is a function "take n list" which returns the first n elements from a list. For example "sum (take 3 xs)" sums up the first three elements in the list xs. Does F# have an equivalent? I expected it to be one of the List-functions, but I can't spot anything that seems to match.
...
I downloaded the scion cabal and am attempting to created scion_server
I ran all of the runghc Setup (configure/build/install)
The Haskell libraries are installed, but the scion_server is not in the ~/.cabal/bin
I have to use a --user on configure so I can install it on just my account.
Any thoughts?
...
I would like to use Parsec's makeTokenParser to build my parser, but I want to use my own definition of whiteSpace. Doing the following replaces whiteSpace with my definition, but all the lexeme parsers still use the old definition (e.g. P.identifier lexer will use the old whiteSpace).
...
lexer :: P.TokenParser ()
lexer = l { P.w...