News aggregator

Tracking down where an instance comes from

haskell-cafe - Sun, 10/26/2014 - 4:14am
Hi, I'm in a situation where we have a 140+ module program (Yi) with some 30+ packages of dependencies and somewhere along the lines, this little guy gets in: instance [safe] Show (a -> b) -- Defined in ‘Text.Show.Functions’ Of course this automatically infects everything to import Yi. This is bad. What would be the best way to track down through which import this actually comes in? There's nothing directly importing Text.Show.Functions and I wonder if there's a better way than ‘remove imports one by one going deeper each time you hit it’ which might take a while, especially as there seems to be no way to unload instances except restarting GHCi.
Categories: Offsite Discussion

Polymorphic functions over string libraries

haskell-cafe - Sun, 10/26/2014 - 2:36am
Hi. I was wondering what would be the best way to create a polymorphic function over any possible string library (Text, String, Bytestring, etc). For instance, imagine I have to read a file with text, transform this text in some way and output it to another file, or to the console. If I wanted to use String, I'd just do this: / transform :: String -> String main = readFile "input.txt" >>= writeFile "output.txt" . transform / But if I wanted to use Text instead, I'd have to use this: / import qualified Data.Text.IO as T transform :: Text -> Text main = T.readFile "input.txt" >>= T.writeFile "output.txt" . transform / Idem for ByteString. I was wondering if there was a way to create these computations in a generic way, for any kind of string library, something like this: / class StringLibrary s where: sReadFile :: FilePath -> IO s sWriteFile :: FilePath -> s -> IO () ... / So then I'd just have this: / transform :: StringLibrary s => s -> s main = sReadFile "input.txt" >>= sWriteFile "output.txt" . transfo
Categories: Offsite Discussion

Monads: external questions

haskell-cafe - Sun, 10/26/2014 - 12:23am
As opposed to the internal logic of monads, how they work, I hope to start a discussion about their external logic: how and why to use monads. design ------ How do monads change the way one * thinks about a problem? * structures data? * refactors? * tests? Should I always be giving the monads a lot of cognitive bandwidth, because they reorder the way everything should be, or is it an investment with a high initial cognitive cost but requiring little maintenance thereafter? what is their common framework? ------------------------------- Monads let data reach farther than it otherwise would. Subjectively, they feel like a controlled way of violating encapsulation. Are there other, deeper or more specific, commonalities that explain why monads are a good way to implement exceptions, output, state, and perhaps other services? varieties --------- In practice, are all monads either for exceptions, state or output? If not, what other goals are monads well suited to? How should multiple contexts coexist? What's
Categories: Offsite Discussion

List functions from type families?

Haskell on Reddit - Sat, 10/25/2014 - 6:08pm

Im trying to get some type-level logic to implement anonymous "flat" sums. I can't figure out how to deal with recursive matching cases though. Something like this compilers, but it doesn't work as well as it should

class Remove (l :: [*]) (t :: *) (ll :: [*]) | l t -> ll instance (x ~ t) => Remove (x ': l) t l instance Rem l t ll => Remove (x ': l) t (x ': ll)

What I'd really like is something like a direct translation of the normal list function

type family Remove (l :: [*]) (t :: *) :: [*] type instance Remove (t ': l) t = l type instance Remove (x ': l) t = x ': Remove l t

but GHC complains about conflicting family instances. Similarly for other list functions like elem. Is there any way massage the compiler into accepting?

submitted by dogirardo
[link] [1 comment]
Categories: Incoming News

Finished reading Learn You a Haskell, please recommend me book number 2:

Haskell on Reddit - Sat, 10/25/2014 - 4:49pm

So, I finished reading Learn You a Haskell (http://learnyouahaskell.com/) and now I need book number two.

I am now taking recommendations: I'd like a book specifically that covers comonads and lens. Anybody know a good second Haskell book to read after your first?

Edit: wow, it's really nice to see I got a lot recommendations for this. I'm very proud to be learning haskell, there's a very positive community behind it no doubt.

submitted by alphonse23
[link] [24 comments]
Categories: Incoming News

a simpler way to declare typeclass instances

haskell-cafe - Sat, 10/25/2014 - 4:42pm
Hello, i am trying to understand how typeclasses work. I know that they can be used as follows (from the manual): data Foo = Foo {x :: Integer, str :: String} instance Eq Foo where (Foo x1 str1) == (Foo x2 str2) = (x1 == x2) && (str1 == str2) I am wondering, why is the following seemingly unambiguous syntax not allowed too? data Foo = Foo { x :: Integer, str :: String } instance Eq Foo (Foo x1 str1) == (Foo x2 str2) = (x1 == x2) && (str1 == str2) If it was allowed, it seems that it could also be applied to records: class HasName r where name :: r -> String data Bird = Bird { name :: String, wingNumber :: Integer } data Person = Person { name :: String, likesBirds :: Bool } instance HasName Bird instance HasName Person Alexey.
Categories: Offsite Discussion

Recursion on TypeNats

glasgow-user - Sat, 10/25/2014 - 2:53pm
If you define your own type level naturals by promoting data Nat = Z | S Nat you can define data families recursively, for example data family Power :: Nat -> * -> * data instance Power Z a = PowerZ data instance Power (S n) a = PowerS a (Power n a) But if you use the built-in type level Nat, I can find no way to do the same thing. You can define a closed type family type family Power (n :: Nat) a where Power 0 a = () Power n a = (a, Power (n-1) a) but this isn't the same thing (and requires UndecidableInstances). Have I missed something? The user guide page is pretty sparse, and not up to date anyway. If not, are there plans to add a "Successor" constructor to Nat? I would have thought this was the main point of using Nat rather than Int. Barney.
Categories: Offsite Discussion

Call-for-help: Add XDGBDS support to `directory` package

libraries list - Sat, 10/25/2014 - 10:43am
Hello *, I'd like to invite everyone with knowledge of the XDG Base Directory Specification[1] to contribute to https://github.com/haskell/directory/issues/6 From what I gathered, it appears to me that adhering to the XDGBD Spec (on Linux at least) is desirable and "strongly encouraged" by Linux distributions[2], so I think this ought to be implemented sooner rather than later (maybe even in time to be part of GHC 7.10.1) This issue was originally filed against GHC, since it affects the location of the `~/.ghc` folder (and fwiw this would also affect cabal's `~/.cabal` folder location). Thanks, hvr [1]: http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html [2]: https://wiki.debian.org/XDGBaseDirectorySpecification
Categories: Offsite Discussion

aeson-t: Transform JSON

Haskell on Reddit - Sat, 10/25/2014 - 10:07am
Categories: Incoming News

Reassociating trees in Template Haskell AST's

Haskell on Reddit - Sat, 10/25/2014 - 4:41am

Disclaimer: crossposted on StackOverflow.

I'm upgrading a library where I translate Haskell to another language. Right now I'm using Meta.Parse to read in a Haskell module, and get back its TemplateHaskell AST, as described here.

The problem I'm running into is that, when I run the parse, I get a bunch of infix operators parsed as UInfixE and UInfixP, meaning that they are of unresolved associativity.

The description of the associativity talks about how the Haskell compiler resolves these.

I'm wondering, is there a function avaliable which can do this reassociation on the trees I get from parsing? I'm looking for something like this:

reassoc :: [Dec] -> [Dec]

I could write the massive AST traversal that does this, but it seems like it would be a massive amount of boilerplate, and clearly the function already exists in some form (hopefully in a form that plays nice with TH).

Does such a thing exist? Is there an easy way to get rid of unresolved infix operators in the AST I get from parsing declarations?

Even a function which, given the Name of an operator, could give its precedence and associativity, would be very useful.

submitted by jmite
[link] [comment]
Categories: Incoming News

Are there ANY good game engines for haskell?

Haskell on Reddit - Fri, 10/24/2014 - 7:54pm

I want to write a really simple intractable physics simulation, and I can't for the life of me find a game engine (really meaning a graphics library with mouse and keyboard functionality). Does anyone know of a good one?

submitted by Undo_all
[link] [38 comments]
Categories: Incoming News

My first package on hackage - feedback please

Haskell on Reddit - Fri, 10/24/2014 - 6:03pm

I created my first package and would like to know if I'm doing things right. Everything from specifying the dependency versions correctly, to documentation tips, to missing cabal file information.

http://hackage.haskell.org/package/aeson-t

Also there's a good chance I should be using lenses or something to do the kinds of transformations that this library provides. I'm still kind of a beginner.

submitted by begriffs
[link] [comment]
Categories: Incoming News

The GHC Team: GHC Weekly News - 2014/10/24

Planet Haskell - Fri, 10/24/2014 - 5:43pm

Hi *,

Welcome to the weekly GHC news. This one will be short this week, as the preceding one occurred only on Monday - but we'll be going with Fridays from now on, so next week we'll hopefully see a longer list.

  • GHC 7.8.4 tickets have been in waiting, and the RC will be soon after Austin finishes some final merges and tests on his branch. We have not committed a time for the release after the RC, yet we would like people to please seriously test and immediately report any major showstoppers - or alert us of ones we missed.
  • For the ​ GHC 7.10 release, one of the major features we planned to try and merge was DWARF debugging information. This is actually a small component of larger ongoing work, including adding stack traces to Haskell executables. While, unfortunately, not all the work can be merged, we talked with Peter, and made a plan: our hope is to get ​Phab:D169 merged, which lays all the groundwork, followed by DWARF debugging information in the code generators. This will allow tools like gdb or other extensible debuggers to analyze C-- IR accurately for compiled executables. Peter has written up a wiki page, available at SourceNotes, describing the design. We hope to land all the core infrastructure in ​Phab:D169 soon, followed by DWARF information for the Native Code Generator, all for 7.10.1
  • This past week, a discussion sort of organically started on the #ghc IRC channel about the future of the LLVM backend. GHC's backend is buggy, has no control over LLVM versions, and breaks frequently with new versions. This all significantly impacts users, and relegates the backend to a second class citizen. After some discussion, Austin wrote up a ​ proposal for a improved backend, and wrangled several other people to help. The current plan is to try an execute this by GHC 7.12, with the goal of making the LLVM backend Tier 1 for major supported platforms.
  • You may notice ​https://ghc.haskell.org is now responds slightly faster in some cases - we've activated a caching layer (CloudFlare) on the site, so hopefully things should be a little more smooth.

Closed tickets this week: #9684, #9692, #9038, #9679, #9537, #1473.

Categories: Offsite Blogs

Building a REST Client

Haskell on Reddit - Fri, 10/24/2014 - 2:56pm
Categories: Incoming News

Typing an AST without loosing the Applicative / Monad instances

Haskell on Reddit - Fri, 10/24/2014 - 10:06am

Hi,

This is my expression tree and related combinators https://github.com/phaazon/ash/blob/master/src/Ash.hs.

I’d like to type it in order to typecheck at compile time so that I can’t, for instance, right an addition of a floating value and an integral value. With the current implementation, I use a nasty L (for litteral) data to represent typed values at runtime, which sucks to me since I have to write a function typecheck :: E a -> Maybe TypeError.

Any idea?

submitted by _skp
[link] [11 comments]
Categories: Incoming News

I have trust issues with Haskell, but I don't think they are justified.

Haskell on Reddit - Fri, 10/24/2014 - 8:23am

I have been a Haskell enthusiast for a while now, but haven't seriously committed to it on any large projects.

The combination of these things leads to this feeling:

  1. Though Haskell is used in some production settings, it doesn't have nearly the amount of use as the other languages/platforms I use.
  2. Sometimes things feel too easy. Like the fact that I don't have a thousand lines of framework setup and configuration. Or that I can just blindly put together things by their types and have them work.
  3. I don't really know what I would do if I ever did have a big problem, especially if this was for my individual business ventures (that is, no buckets of money to throw at the problem).

I am able to create software more easily, and it seems much more reliable, and this worries me.

Are these completely unfounded?

submitted by fear-of-flying
[link] [34 comments]
Categories: Incoming News