News aggregator

Any pointers on how to build a Windows DLL from Haskell code?

Haskell on Reddit - Wed, 07/15/2015 - 2:46pm

Does anyone have experience building a Windows DLL from Haskell code and then calling it from C++ code? I’m having a tough time just getting the DLL built. I opened this Stack Overflow question to ask about the specific problem I’m having right now, but I’d appreciate any advice people can offer.

(It seems like calling C code from Haskell is by far the more common use of the FFI. Information on building a DLL is hard to find and a lot of what I’ve seen is contradictory—if I ever figure this out I’ll write a detailed blog post with instructions and pointers.)

submitted by bdesham
[link] [13 comments]
Categories: Incoming News

FLOPS 2016, Second CFP

General haskell list - Wed, 07/15/2015 - 2:32pm
FLOPS 2016: 13th International Symposium on Functional and Logic Programming March 3-6, 2016, Kochi, Japan Call For Papers http://www.info.kochi-tech.ac.jp/FLOPS2016/ New: best paper award; in-cooperation with ACM SIGPLAN Writing down detailed computational steps is not the only way of programming. The alternative, being used increasingly in practice, is to start by writing down the desired properties of the result. The computational steps are then (semi-)automatically derived from these higher-level specifications. Examples of this declarative style include functional and logic programming, program transformation and re-writing, and extracting programs from proofs of their correctness. FLOPS aims to bring together practitioners, researchers and implementors of the declarative programming, to discuss mutually interesting results and common problems: theoretical advances, their implementations in language systems and tools, and applications of these systems in practice. The scope includes all
Categories: Incoming News

[ANN] frpnow-0.12

haskell-cafe - Wed, 07/15/2015 - 2:25pm
Dear Cafe, We have released the (nearly) first version of FRPNow, the functional reactive programming library based on the ICFP 2015 paper "Principled Practical FRP: Forget the Past, Change the Future, FRPNow!" ( https://www.reddit.com/r/haskell/comments/3ai7hl/principled_practical_frp_forget_the_past_change/ ) The main package: http://hackage.haskell.org/package/frpnow Examples: https://github.com/atzeus/FRPNow/tree/master/Examples Gloss interoperability: http://hackage.haskell.org/package/frpnow-gloss GTK interoperability: http://hackage.haskell.org/package/frpnow-gtk (hackage doesn't like the newer GTK docs, so you can read the docs at http://www.cse.chalmers.se/~atze/frpnow-gtk/ ) Cheers, Atze _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe< at >haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Categories: Offsite Discussion

Why can't we have an EitherT in transformers?

Haskell on Reddit - Wed, 07/15/2015 - 10:45am

It still confuses me that Either never had an accompanying EitherT in transformers, like MaybeT for Maybe. What is the reason for Either to be excluded?

(I know about Control.Monad.Except etc but those are besides the point)

As it is now, to get an EitherT one must import a separate library EitherT but that has been deprecated in favor of either which has a lot of dependencies from outside of base and transformers. I don't doubt those are all good, but it is kind of overkill to pull all of them just to get an either transformer.

Even more strange is that either has mtl as a dependency, while mtl is another set of transformers that lives under a different namespace (Control.Monad rather than Control.Monad.Trans).

(I also just realized that there is no Control.Monad.MaybeT in mtl, so one has to import MaybeT to get that one.)

submitted by togrof
[link] [32 comments]
Categories: Incoming News

Question about the format of Type Declaration

Haskell on Reddit - Wed, 07/15/2015 - 9:40am

I'm currently working my way through Learn You a Haskell for Great Good and there is a part where he declares a function type like so:

lucky :: (Integral a) => a -> String lucky 7 = "LUCKY NUMBER SEVEN!" lucky x = "Sorry, you're out of luck, pal!"

I was just curious why you would do this instead of:

lucky :: Int -> String

Is it just good practice to be as general as possible?

submitted by ThreeFreeTrees
[link] [5 comments]
Categories: Incoming News

Announce: FRPNow-0.12

Haskell on Reddit - Wed, 07/15/2015 - 7:21am

We have released the (nearly) first version of FRPNow, the functional reactive programming library based on the ICFP 2015 paper "Principled Practical FRP: Forget the Past, Change the Future, FRPNow!".

The main package: http://hackage.haskell.org/package/frpnow

Examples: https://github.com/atzeus/FRPNow/tree/master/Examples

Gloss interoperability: http://hackage.haskell.org/package/frpnow-gloss

GTK interoperability: http://hackage.haskell.org/package/frpnow-gtk

(hackage doesn't like the newer GTK docs, so you can read the docs here)

submitted by atzeus
[link] [35 comments]
Categories: Incoming News

readMaybe for `ReadS a`

Haskell on Reddit - Wed, 07/15/2015 - 6:48am

So, in Text.Read, there is a function readMaybe. We all love this. Is there a similar function like this:

readMaybe :: Read a => String -> Maybe a -- actually exists readsMaybe :: ReadS a -> String -> Maybe a -- hypothetically could exist

I'm asking this because there are some handy read/show functions for RGB colors, but there is no safe way to read strings with them. If anyone knows of a library that provides this, that would be great.

submitted by andrewthad
[link] [9 comments]
Categories: Incoming News

Does Haskell have slow iteration times? Are those a problem?

Haskell on Reddit - Wed, 07/15/2015 - 5:32am

I was re-reading an old article today (http://gamesfromwithin.com/whats-your-pain-threshold) and remembered people complaining about Haskell slow compilation times (especially with frameworks like yesod).

This lead me to several questions:

  1. Do you have slow iteration (complie+test+run) times?
  2. How do you deal with that? Solutions?
  3. Do you find it negatively affects your productivity when the compile+test+execute cycle take longer?
  4. What are your solutions?
submitted by tmnt9001
[link] [85 comments]
Categories: Incoming News

Haskell & Java/Scala interoperbility?

haskell-cafe - Wed, 07/15/2015 - 3:14am
Hello, I have been looking at Hackage for a package/library that supports Haskell interoperability with Java/Scala. Didn't see any such support. If true, is there any project in the works? Thanks, Vasili
Categories: Offsite Discussion

Is this reasoning correct?

Haskell on Reddit - Wed, 07/15/2015 - 2:33am

Hello, I'm studying the fold functions and I have read that the recursive pattern abstracted by foldl is:

f v [] = v f v (x:xs) = f (v ⊕ x) xs

and the recursive pattern abstracted by foldr is:

f [] = v f (x:xs) = x ⊕ f xs

Now, I'm trying to see if the foldl pattern can be expressed as the foldr pattern following these steps:

let g = f v (x ⊛ v) = (x (flip ⊕) v) = (v ⊕ x) then f v [] = v f v (x:xs) = f (v ⊕ x) xs becomes g [] = v g (x:xs) = f (x ⊛ v) xs which then I can rephrase g [] = v g (x:xs) = (x ⊛ v) `f` xs

If I could somehow group v and f I would get:

g [] = v g (x:xs) = x ⊛ g xs

which is where I'm trying to get but I don't know any property that would let me do that which makes me ask: Am I doing some step wrong? Or simply those patterns aren't equivalent and the whole thing is pointless?

Thanks!

submitted by anler
[link] [6 comments]
Categories: Incoming News

Are sandboxes relevant to stack?

Haskell on Reddit - Wed, 07/15/2015 - 12:32am

I'm still wrapping my head around how stack works. Coming from cabal, I understand sandboxes are a cabal thing, does stack obviate the need for them (if so, how)? Can stack interact with sandboxes?

submitted by klaxion
[link] [12 comments]
Categories: Incoming News

Just getting started - What are you recommended tools/editors/OS for developing with Haskell?

Haskell on Reddit - Tue, 07/14/2015 - 11:53pm

I'm totally new to Haskell, though I've worked with ML and Racket in the past. I wanted to impart upon the wisdom of /r/haskell, and see what recommended tools, editors, and development environments exist for this language.

I'm currently using gVim or Notepad++ on Windows, but would be interested in switching to Linux if it offers a better developer experience.

I've also tried using SublimeText3 on Windows, but have had some integration issues when installing packages with cabal that ST3 needs.

submitted by komplete
[link] [29 comments]
Categories: Incoming News

Is it possible to create a data type that can take any number of type parameters?

Haskell on Reddit - Tue, 07/14/2015 - 10:49pm

Lets say I want to create a datatype for vectors, is it possible to make it so the type constructor can take any number of values so you can make any size vector?

submitted by Grantselrich
[link] [5 comments]
Categories: Incoming News

Christopher Done: Use the REPL, Luke

Planet Haskell - Tue, 07/14/2015 - 6:00pm

There was an online discussion about iteration times in Haskell and whether and why they are slow. For me, it’s not slow. I do all my Haskell development using a REPL. Here are some tips I wrote up in that discussion.

Prepare for GHCi use

The first thing you want to do before writing anything for your project is make sure you can load your code in the REPL; GHCi. Sometimes you have special configuration options or whatnot (cabal repl and stack ghci make this much easier than in the past). The sooner you start the better. It can be a PITA to load some projects that expect to just be a “start, run and die” process, they often launch threads without any clean-up procedure; in this way the REPL makes you think about cleaner architecture.

Make sure it scales

Learn how to make GHCi fast for your project so that you don’t hit a wall as your project scales. Loading code with byte-code is much faster than object code, but loading with object code has a cache so that in a 100 module project if you only need to reload one, it’ll just load one. Make sure this is happening for you, when you need it. Dabble with the settings.

Write small, parametrized functions

Code that is good for unit tests is code that is good for the REPL. Write small functions that take state as arguments (dependency injection) rather than loading their own state, then they can be ran in the REPL and used in a test suite easily. Regard functions that you can’t just call directly with suspicion.

Test work-in-progress implementations in the REPL

While writing, test your function in the REPL with typical arguments it will expect, rather than implementing a function and then immediately using it in the place you want to ultimately use it. You can skip this for trivial “glue” functions, but it’s helpful for non-trivial functions.

Setup/teardown helpers

Write helpful setup/teardown code for your tests and REPL code. For example, if you have a function that needs a database and application configuration to do anything, write a function that automatically and conveniently gets you a basic development config and database connection for running some action.

Make data inspectable

Make sure to include Show instances for your data types, so that you can inspect them in the REPL. Treat Show as your development instance, it’s for you, don’t use it for “real” serialization or for “user-friendly” messages. Develop a distaste for data structures that are hard to inspect.

Figure out the fastest iteration for you

Use techniques like :reload to help you out. For example, if I’m working on hindent, then I will test a style with HIndent.test chrisDone "x = 1", for example, in the REPL, and I’ll see the output pretty printed as Haskell in my Emacs REPL. But I work on module HIndent.Style.ChrisDone. So I first :load HIndent and then for future work I use :reload to reload my .ChrisDone changes and give me the HIndent environment again.

Configuration

Make sure you know about the .ghci file which you can put in your ~/ and also in the project directory where GHCi is run from. You can use :set to set regular GHC options including packages (-package foo) and extensions (-XFoo), and any special include directories (-ifoo).

More advanced tricks

Consider tricks like live reloading; if you can support it. I wrote an IRC server and I can run it in the REPL, reload the code, and update the handler function without losing any state. If you use foreign-store you can make things available, like the program’s state, in an IORef or MVar.

This trick is a trick, so don’t use it in production. But it’s about as close as we can get to Lisp-style image development.

In summary

Haskell’s lucky to have a small REPL culture, but you have to work with a Lisp or Smalltalk to really know what’s possible when you fully “buy in”. Many Haskellers come from C++ and “stop program, edit file, re-run compiler, re-run whole program” cycles and don’t have much awareness or interest in it. If you are such a person, the above probably won’t come naturally, but try it out.

Categories: Offsite Blogs

Bryn Keller: Higher Order Type Theory Resources

Planet Haskell - Tue, 07/14/2015 - 6:00pm

Recently there’s been an outpouring of useful resources folks have found for learning Homotopy Type Theory (aka HoTT). These have come mainly from the HoTT Cafe Google Group.

The main resource is of course, the book, but these videos and other resources seem useful enough that I want a consolidated list of them for myself. So I thought maybe you might, too.

Group threads that provided these links:

Note that I’m likely to update this page in the future with other resources as I find them, and those links may or may not come from the Groups threads just mentioned.

Useful resources, in no particular order:

Related:

Categories: Offsite Blogs

Saving functions

Haskell on Reddit - Tue, 07/14/2015 - 3:10pm

Stumbled upon the spoon package. I wanted to see if I could make it work for functions instead of just values. After fiddling around with functional dependencies I've managed to get something that works! The code is very short so I'll post the whole thing.

{-# LANGUAGE FlexibleContexts , FlexibleInstances , UndecidableInstances , TypeFamilies , FunctionalDependencies #-} module Control.Safezone where import qualified Control.Exception as Exc import System.IO.Unsafe {-# NOINLINE unsafeCleanup #-} unsafeCleanup :: a -> Maybe a unsafeCleanup x = unsafePerformIO $ Exc.catch (x `seq` return (Just x)) handler where handler :: Exc.ErrorCall -> IO (Maybe a) handler _ = return Nothing class Save f g | f -> g where save :: f -> g instance {-# OVERLAPPABLE #-} (b ~ Maybe a) => Save a b where save = unsafeCleanup instance Save f g => Save (a -> f) (a -> g) where save f x = save (f x) unsafeDiv :: Double -> Double -> Double unsafeDiv x y | y /= 0 = x / y | y == 0 = error "Dividing by zero" --safeDiv :: Double -> Double -> Maybe Double safeDiv = save unsafeDiv

The result is the magical save function that you can apply to any other function (of arbitrary arity) and it will wrap the END result of that function into a Maybe. Just when everything goes well, Nothing when there's an exception.

I'm not sure if there's any practical use case where this is advantageous over just spooning the return value but I guess it's at least more compact. As you can see it's about as offensive to safety as is gets. All it's lacking is TH :D

I've commented out the type signature of safeDiv to show that the type is successfully inferred.

Edit:

I mean, come on. This is pretty neat stuff

safeRead :: Read a => String -> Maybe a safeRead = save read *Control.Safezone> safeRead "123" :: Maybe Int Just 123 *Control.Safezone> safeRead "123a" :: Maybe Int Nothing submitted by Darwin226
[link] [3 comments]
Categories: Incoming News