What is implicit recursion?
What is implicit recursion? How is it different from explicit recursion? ...
What is implicit recursion? How is it different from explicit recursion? ...
Can anybody explain what the difference is in Haskell between the dot (.), and the dollar sign ($). As I understand it, they are both syntactic sugar for not needing to use parentheses. ...
Hi, I'm a newbie to Haskell, and I'm trying to write an elegant function to merge an arbitrary number of sorted lists into a single sorted list... Can anyone provide an elegant and efficient reference implementation? Thanks! ...
I have a function that checks whether a type is a subtype of another type: st :: Monad m => Map String Type -- ^type environment -> Set (Type, Type) -- ^assumed subtypes -> (Type, Type) -- ^we are checking if lhs <: rhs -> m (Set (Type, Type)) I want to do error handling. I have the following definition: instance Mona...
A phrase that I've noticed recently is the concept of "point free" style... First, there was this question, and also this one. Then, I discovered here they mention "Another topic that may be worth discussing is the authors' dislike of point free style." What is "point free" style? Can someone give a concise explanation? Does it have s...
Is there any standard or "most usual" way to represent multidimensional sparse arrays in Haskell (without sacrificing performance too much)? Something like map< int, map< int, MyClass> > in C++, for example. I've Googled and found just some old academic papers and other people asking for this too. Thanks! ...
Hi I'm using the Haskell platform on Windows and I'd like to write a small program which can draw graphs. The graph should be exported to any image format (or even PDF). What is the easiest way to accomplish this? (By graph I mean plot.) ...
I know several games have been coded in Haskell, but being a newbie I don't yet consider myself capable of judging quality of coding (idiomatic style, etc.) Can anyone recommend the source of a particular game written in Haskell as a learning exercise? (As a side note, the simpler the game, the better, really. I'd especially be thrille...
How can I make the genOut/String fire? module IOStream where import System.IO import System.IO.Unsafe class Out a where out :: a → String instance Show a ⇒ Out a where out = show outString :: String → String outString = id {-# RULES "genOut/String" out = outString #-} infixl 9 <<, ≪ (≪), (<<) :: Out a ⇒ IO Handle → a → IO Handl...
I completely forgot about my Haskell project which is due in a couple of hours, any help would be appreciated. The first part is an evaluation function that has the following type signature: evaluate :: Logic Expr -> [(Variable, Bool)] -> Bool This takes a logic expression and a list of assignment pairs as input and returns the value...
i'm confused about the notion of "spark" Is it a thread in haskell ? or is the action of spawning a new thread ? Thanks everybody: So to summarize, sparks are not thread but more of unit of computation (tasks to put it in C#/Java terms). So it's the haskell way of implementing the task parallelism ...
The show function in Haskell doesn't seem to do what it should: Prelude> let str = "stack\n\noverflow" Prelude> putStrLn str stack overflow Prelude> show str "\"Stack\\n\\n\\noverflow\"" Prelude> When I declare functions, I normally put the type signatures as Show, which doesn't deal with newlines correctly. I want it to treat \n as...
I hope this is a valid post for these forums I am trying to revise for my functional programming exam, and am stumped on the first questions on past papers, and yes, we arent allowed solution sheets, here is an example of the 1st question on a past paper For each of the following expressions give its type in Haskell (for an expression...
let's say I've got the following type : data MyType = Constructor0 | Constructor1 | Constructor2 deriving (Eq,Show,Enum) Is there a way to create one of such instances : MArray (STUArray s) MyType (ST s) MArray IOUarray MyType IO For the moment I store everything as Word8 and I make conversion with (wrapped) fromEnum/to...
Hi, I need the Numeric.FAD library, albeit still being completely puzzled by existential types. This is the code: error_diffs :: [Double] -> NetworkState [(Int, Int, Double)] error_diffs desired_outputs = do diff_error <- (diff_op $ error' $ map FAD.lift desired_outputs)::(NetworkState ([FAD.Dual tag Double] -> FAD.Dual tag Double)) ...
I've written a small Scheme interpreter in C#, and realised that the way I had implemented it, it was very easy to add support for proper continuations. So I added them... but want to "prove" that they way that I've added them is correct. My Scheme interpreter however has no support for "mutating" state - everything is immutable. So i...
Suppose I am defining a Haskell function f (either pure or an action) and somewhere within f I call function g. For example: f = ... g someParms ... How do I replace function g with a mock version for unit testing? If I were working in Java, g would be a method on class SomeServiceImpl that implements interface SomeService. ...
I know newtype is more often compared to data in Haskell, but I'm posing this comparison from more of a design point-of-view than as a technical problem. In imperitive/OO languages, there is the anti-pattern "primitive obsession", where the prolific use of primitive types reduces the type-safety of a program and introduces accidentally ...
I came across the following definition as I try to learn Haskell using a real project to drive it. I don't understand what the exclamation mark in front of each argument means and my books didn't seem to mention it. data MidiMessage = MidiMessage !Int !MidiMessage Thanks for any responses ...
I've frequently heard claims that Haskell doesn't have varibles; in particular, this answer claims that it doesn't, and it was upvoted at least nine times and accepted. So does it have variables or not, and why? This question also appears to apply ML, F#, OCaml, Erlang, Oz, Lava, and all SSA intermediate languages. I'd appreciate a co...