hdevtools previously had an issue where it wouldn't work with stack databases. There is a pull request currently that lets hdevtools work with stack projects.
I've tested it against all of my own Haskell projects and it works. If you'd like to give it a shot, please post your experience!
- Clone the repository here
- stack build && stack install
- Test hdevtools with your stack enabled projects
[link] [39 comments]
How different is the garbage collector of a language like Haskell compared to the one of a language like Java. Objects in Haskell are typically immutable and IDless. Programmers have a much more restricted control over objects, which, I guess, is translated to easier job for the GC. I was looking at the eventlog of my program in ThreadScope and realized that the GC, in some cases, stops the other threads in order to cleanup the memory. Why does GC actually need to stop the world if all the objects are immutable?submitted by gtab62
[link] [7 comments]
From my indoctrination years ago, OO is the solution to the problem in C where we'd have:
- Lots of data structures such as arrays of arrays and other items, and
- functions which would operate on them.
The purported problem (probably true) was that the data wasn't capable of "protecting itself" from incorrect use. Additionally, lots of bad uncompartmentalized design resulted. E.g., no encapsulation. Nevertheless, in better designed C-based systems, highly defined function interfaces are the rule, I believe.
This has carried forward to today where frameworks like Ruby on Rails makes use of Models. These;
- keep all the data related to an entity,
- restrict access to their data,
- know how to validate their own state,
- are the locus of business logic for that entity, and
- manage their persistence.
The foundations for these features seem to be (1) message sending and (2) ability to create new 1st-class types. One sends a message to an object, and it "does the right thing" for itself and its data.
Finally, my question: What are the Haskell/Snap/Yesod solutions and equalivalents? Concretely, instead of having a programmer-written OO Class Restaurant which responds appropriately to the .latest_inspection message, how would this be designed in a Haskell system?
(Yes, I'm writing apps and libraries for publishing restaurant inspections. :-)submitted by dogweather
[link] [50 comments]
I was just playing around when I realised I could do thisinfixl 2 if' if' :: a -> Bool -> Maybe a if' a True = Just a if' _ False = Nothing infixr 1 else' else' :: Maybe a -> a -> a else' = flip fromMaybe
This lets you do stuff likea `if'` test `else'` b a `if'` test `else'` b `if'` test' `else'` c
if' is a useful function on its own.
Yes, it looks pretty ugly with all the quotes and backticks, and the functions could benefit from better names or being operators, but its pretty cool. Thought I'd share.submitted by 0v3rk1ll
[link] [22 comments]
From Greg Weber's blog post on stack - http://tech.frontrowed.com/post/122556313986/stack-at-front-row-education - "The good news is that you can build a project with both cabal and stack and the two tools will not conflict."
I've been trying to figure out a clean way of doing that without any success. Tools like ghc-mod only work with cabal and I would like to be able to use them with stack.
My initial assumption was that I can simply get cabal to use the stack package databases by passing --package-db=clear --package-db=<stack snapshot db> --package-db=<stack local db> to cabal configure, but cabal is still not able to find the dependencies already installed by stack.
Is there a clean documented way to achieve this?submitted by haskman
[link] [9 comments]
About a year ago a few friends of mind were interested in learning Haskell, so I put together a few blog posts to serve as a "crash-course". I've only now gotten around to putting them online, but they cover the basics of syntax, using cabal, typeclasses and Prelude typeclasses, and some of the more abstract ones as well. These won't really be great for everyone since I wrote them with a few specific people in mind, but perhaps someone will enjoy them!
Finger Trees -- this one is an older one, maybe even has been on this sub before.
If you find any errors (logical or formatting), please let me know!submitted by NiftyIon
[link] [10 comments]
Considering Haskell uses call-by-need evaluation, you are never really applying a function to anything. All your code describes what things are and not how they are computed.
For example,map :: (a -> b) -> [a] -> [b] map _  =  map f (x:xs) = f x : map f xs
The name "map" acts like a verb, as if the code were "mapping" the function over a list. But, actually, the code is just describing how a new list of "b" can be produced out of a list of "a" and a function "a -> b". Would a name like "mappedBy" make more sense?mappedBy :: [a] -> (a -> b) -> [b]  `mappedBy` _ =  (x:xs) `mappedBy` f = f x : xs `mappedBy` f
I see Haskell library uses verbs and adjectives (or "properties") to name functions. There is no standard or "correct" way to name stuff?
Other examples:insert :: Ord a => a -> [a] -> [a] -- verb style insert x xs = ... with :: Ord a => [a] -> a -> [a] -- adjective/property style xs `with` x = ... length :: [a] -> Int -- adjective/property style length xs = ... getLength :: [a] -> Int -- verb style getLength xs = ... sort :: Ord a => [a] -> [a] -- verb style sort xs = ... sorted :: Ord a => [a] -> [a] -- adjective/property style sorted xs = ... sortBy :: (a -> a -> Ordering) -> [a] -> [a] -- verb style sortBy f xs = ... sortedBy :: [a] -> (a -> a -> Ordering) -> [a] -- adjective/property style xs `sortedBy` f = ... on :: (b -> b -> c) -> (a -> b) -> a -> a -> c -- adjective/property style f `on` g = ... applyBeforeAndThen :: (a -> b) -> (b -> b -> c) -> a -> a -> c -- verb style applyBeforeAndThen g f = ... submitted by evohunz
[link] [8 comments]
There are two boxes on a table, one red and one green. One contains a treasure. The red box is labelled "exactly one of the labels is true". The green box is labelled "the treasure is in this box."
Can you figure out which box contains the treasure?
The treasure is in the red box
The treasure is in the green box
There is not enough information to determine the answer
Starting on 2015-07-03, the solution will be here.
What's the trick?submitted by clrnd
[link] [19 comments]
I'll get to the point. I use emacs. I use this guide to set up emacs. Things had been working pretty seamlessly for the past few months. Then they stopped working so great. I started getting weird errors. Whereas it used to look like this now it looks like this.
I don't want to have to mess with this. I've contemplated just uninstalling everything, reinstalling haskell-platform, recompiling GHC, reinstalling emacs, downloading all of the emacs packages, etc.
Problem: I don't want to have to do this shit every time emacs messes up on my 3 different devices I work on.
Solution: I'm going to write a bash/python script that does all of it for me.
Question: Has this already been solved? Is there like, a container or Nix config file that does all of this for me already? It would be great if so.submitted by socratesthefoolish
[link] [4 comments]