Tag: Haskell
Posts of Tag: Haskell
Posts of Tag: Haskell
How can I change my data types without causing a recompile in Haskell?
After watching a video of a talk by Bret Victor, I was inspired to write a quick hack that was somewhat similar to a development environment he demonstrated in the talk. Basically the idea is, one has the app r...Learn MoreHaskellCPU emulation in haskell, functional data structures, and maybe zippers?
Well, not exactly. I have more of a functional data structures question. Say I want to model the execution of a CPU. I have some set of instructions that mutate the CPU state (say it's a stack based cpu. Only ...Learn MoreHaskellfunctional-programmingHow to change function calls with parenthesis using composition in Haskell?
Here's what I write: (take 2 (repeat " ")) I want to change it to expr without parenthesis. Can I use "." like so: ceiling (negate (tan (cos (max 50 x)))) can be changed to ceiling . negate . tan . cos . m...Learn MoreHaskellComparing list length with arrows
Inspired by Comparing list length If I want to find the longest list in a list of lists, the simplest way is probably: longestList :: [[a]] -> [a] longestList = maximumBy (comparing length) A more effic...Learn MorelistComparisonHaskellarrowsError building GHC on Windows
While attempting to bootstrap Haskell on Windows without the Haskell Platform I ran into the following error C:\git\Haskell\ghc\libraries\haskeline\dist-install\build/libHShaskeline-0.7.1.2.a: could not rea...Learn MoreHaskellGhcHaskell tail recursion predictability
One of the biggest issues I have with haskell is to be able to (correctly) predict the performance of haskell code. While I have some more difficult problems, I realize I have almost no understanding. Take some...Learn MoreOptimizationHaskellChecking if a string consists of balanced parenthesis
I wrote the following program to check strings for balanced parenthesis: isBalanced xs = isBalanced' xs [] isBalanced' [] [] = True isBalanced' [] _ = False isBalanced' ('(':xs) ys = isBalanced' xs (')':ys) ...Learn MoreRecursionHaskellpattern-matchingformal-languagespushdown-automatonHaskell - Filtering Lists by Comparison
I need to filter a list with a mask in Haskell. It applies the function to an element of the mask list and the corresponding element in the data list, and if the function returns true, the corresponding element...Learn MorelistHaskellCompareUnboxing boxed value in vector of four tuples
There is a performance issue I am trying to debug as part of a more complicated code. It seems that append function that I am using to create a dynamic, growable vector of (Int,Int,Int,Int) is causing one of th...Learn MorePerformanceVectorHaskellGhcunboxingHaskell: Lists vs Streams
I've noticed streams seem to act a lot like lists, except with constant time append. Of course, adding constant time append to lists isn't too complicated, and DList does exactly that. Lets assume for the rest...Learn MoreStreamlistHaskellPattern matching against a tuple in the IO Monad in Haskell
I've been studying Haskell in my spare time and have recently crossed into the area of monadic functions. I've distilled the code from an excercise I've been working on into this very contrived example to isola...Learn MoreHaskellTuplespattern-matchingHaskell: Appending to a list from multiple locations in a program
I would like to have a list that may be updated (appended to) from more than one location in the code. Since in haskell, calling a function once is the same as calling it twice and discarding the result of the ...Learn MoreMemoizationHaskellfunctional-programmingglobal-variables