News aggregator

Help with Data.Map (new to haskell ..)

Haskell on Reddit - Mon, 11/03/2014 - 4:57pm

Hey guys,

I've been looking on the web on how haskell works, but even with google's help I can't figure out what's wrong with my code:

import qualified Data.Map as Map data Env = EmptyEnv | BasicEnv Map.Map String Val | ExtendEnv String Val | GetEnv Env String Val deriving (Show, Eq)

The error is this:

Expecting two more arguments to `Map' Expected a type, but `Map' has kind `* -> * -> *' In the type `Map' In the definition of data constructor `BasicEnv' In the data declaration for `Env' Failed, modules loaded: none.

Val is another type I deffined.

Until now this tutorial has been helpfull, but now I'm stuck..

Edit: Mistake in the title, I wanted to say that I'm "new to haskell" :)

Solved:

BasicEnv (Map.Map String Val)

Works!

Thanks for the help guys!

submitted by husky11
[link] [4 comments]
Categories: Incoming News

ANN: Released new version of Haskell plugin forIntelliJ

haskell-cafe - Mon, 11/03/2014 - 10:57am
Hi everyone, I'm glad to announce version 0.2. It's available in Jetbrains plugin repository. Besides improvements and minor changes, version 0.2 has support for HLint inspection and quick fixes based on HLint suggestions. For more information, see change notes. Complete feature list is now: - Syntax highlighting (which can be customized); - Error/warning highlighting; - Find Usages of identifiers; - Resolving references of identifiers (also to library code if library source code is added to project and resolves inside import declaration); - Code completion by resolving references; - Renaming variables (which first shows preview so refactoring scope can be adjusted); - View type info from (selected) expression; - View expression info; - View quick documentation; - View quick definition; - Structure view; - Navigate to declaration (called `Class` in IntelliJ menu); - Navigate to identifier (called `Symbol` in IntelliJ menu); - Code completion by looking to import declarations; - Simple form of code for
Categories: Offsite Discussion

Pattern variables in Template Haskell

haskell-cafe - Mon, 11/03/2014 - 10:07am
Dear Haskell-cafe, I'm trying to use Template Haskell to generate patterns in Haskell code, but after a couple of days of trying, I have not come with a solution. I hope somebody could help me. My problem is basically that I want something like: example :: Maybe a -> a example $(j "x") = x to work correctly. The idea of this simple quoter is to generate code similar to: example :: Maybe a -> a example (Just x_123) = x_123 that is, to create the "Just" pattern, and to make "x" bind to the same element. Right now my code reads: j :: String -> Q Pat j s = return (ConP 'Just [VarP (mkName s)]) which generated a new variable "x" each time, thus unable to match with the "x" in the RHS. I have also tried with lookupValueName. Note that my problem is a bit more complicated, with variable names coming from a different source. However, I think that if I solve this problem where I can make variables in a pattern and in an expression match, I should be able to use them in my complete solution. Thanks in advance
Categories: Offsite Discussion

Douglas M. Auclair (geophf): October 2014 1HaskellADay Problems and Solutions

Planet Haskell - Mon, 11/03/2014 - 6:18am

October, 2014
  • October 1st, 2014, Wednesday: Pathways into Darkness http://lpaste.net/111444 Because Daerkness is the new Pink. Today's #haskell problem. ...AAAAAND we went there: Dark, Darkest, Darko! http://lpaste.net/111919 A solution to the #haskell grid-pathing problem using Data.Graph. FUN!
  • October 2nd, 2014, Thursday: Tweet, tweet! Summer Factorial! http://lpaste.net/111947 a #haskell 'sum'mer exercise for the Fall. From "Power set, HO!" to "Power Sets? NO!" http://lpaste.net/111982 A solution to today's longest factors-sum #haskell problem.
  • October 3rd, 2014, Friday: In which I get WHACKED by the Missus for today's #haskell problem http://lpaste.net/112005 (I've printed out the word-ladders in long form so you can give them to your Missus, thus to avoid enWHACKification! http://lpaste.net/112009) GROSS ('Get Rid Of Stupid wordS') club and goal-directed searches using Levenstein distances give us today's solution http://lpaste.net/112064
  • BONUS! puzzles for today: YOU get RICK ROLLED! http://lpaste.net/112006 Oh, yeah! I went there!
<object class="BLOGGER-youtube-video" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" data-thumbnail-src="https://ytimg.googleusercontent.com/vi/dQw4w9WgXcQ/0.jpg" height="266" width="320"><param name="movie" value="https://youtube.googleapis.com/v/dQw4w9WgXcQ&amp;source=uds"/><param name="bgcolor" value="#FFFFFF"/><param name="allowFullScreen" value="true"/><embed allowfullscreen="true" height="266" src="https://youtube.googleapis.com/v/dQw4w9WgXcQ&amp;source=uds" type="application/x-shockwave-flash" width="320"></embed></object>
  • You can't kill the metal, unless you're Rick Rolled; solution to #haskell bonus problem at http://lpaste.net/112127
<object class="BLOGGER-youtube-video" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" data-thumbnail-src="https://ytimg.googleusercontent.com/vi/MmpnBGtoG0M/0.jpg" height="266" width="320"><param name="movie" value="https://youtube.googleapis.com/v/MmpnBGtoG0M&amp;source=uds"/><param name="bgcolor" value="#FFFFFF"/><param name="allowFullScreen" value="true"/><embed allowfullscreen="true" height="266" src="https://youtube.googleapis.com/v/MmpnBGtoG0M&amp;source=uds" type="application/x-shockwave-flash" width="320"></embed></object>

  • October 4th, 2014: Dear Dad, SEND + MORE = MONEY http://lpaste.net/112160 Today's #haskell problem. Problem SOLVED! (naively) ... for a small processing fee, ... ;) http://lpaste.net/112175
  • October 7th, 2014: An American Family http://lpaste.net/112220 Today's #haskell problem gives us the #Twilight lexicon... in a 'VERY' 'BRIEF' synopsis. #ontology 8 of 21 questions are answered against the #Twilight (extended) family tree http://lpaste.net/112307  My enthusiasm overcame my reasonableness.
  • BONUS #haskell problem for today! http://lpaste.net/112229 Renesmee's (doting) Aunts because EVERYONE dotes on Renesmee. By law. Do-it-to-it! "And Bella Swan lived Happily Ever After" ... and that's the whole point of the 4-book #twilight series. http://lpaste.net/112339 #ontology
  • October 8th, 2014: "A more clever approach than brute force is desirable" for today's #haskell problem http://lpaste.net/112310 (Me? Brute Force, All the WAY!) (Not so) Brutish pathing through triangular sums ... Commited Choice FTW! http://lpaste.net/112355 A solution to today's #haskell problem.
  • October 9th, 2014: Sugar and spice and everything nice (http://lpaste.net/111904): that's what today's #haskell problem from a logic puzzle from 1957 is made of. A long path to a solution to this day's engagement announcements #haskell problem, involving monoidal Frege logic. http://lpaste.net/112446
  • October 10th, 2014: "Oh, it's 4:42. No, it isn't, ... zzzz" Those kinds of conversations come up all the time in today's #haskell problem http://lpaste.net/112404 And the poor little matchstick boy went back to sleep in his warm, comfy bed, hot chocolate by his bedside http://lpaste.net/112461 a solution
  • BONUS! Okay, so you're saying liars ALWAYS lie and TruthTellers ALWAYS tell the truth. http://lpaste.net/112405 Wait ... even in Vegas? #Bonus In which we may learn about your sense of humo(u)r http://lpaste.net/112508 a solution using logic, meta-logic, and coercive logic. #ontology 
  • October 13th, 2014: In which we discover Columbus is Big in Japan ... no, wait: that's #ekmett. http://lpaste.net/112511 Today's #haskell problem. We solve this problem by WAY overusing the State Monad! http://lpaste.net/112537 ... Letter to a Young Haskell Enthusiast should have added: "Don't overused the State Monad!" I hear and obey the advice of ekmett!
<object class="BLOGGER-youtube-video" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" data-thumbnail-src="https://ytimg.googleusercontent.com/vi/tl6u2NASUzU/0.jpg" height="266" width="320"><param name="movie" value="https://youtube.googleapis.com/v/tl6u2NASUzU&amp;source=uds"/><param name="bgcolor" value="#FFFFFF"/><param name="allowFullScreen" value="true"/><embed allowfullscreen="true" height="266" src="https://youtube.googleapis.com/v/tl6u2NASUzU&amp;source=uds" type="application/x-shockwave-flash" width="320"></embed></object>

  • What time is it? π-time? No. (But you were close ...) It's BONUS #haskell problem time! http://lpaste.net/112515 Go discover the New World! And, we discover, solving this bonus problem, that the New World was India (and not the ink), no matter what anyone else says, eh, Columbus? http://lpaste.net/112533
  • October 14th, 2014: We look at reciprocally-cycled decimal values of fractions in today's #haskell problem http://lpaste.net/112565 In which we discover that @geophf must read the problem statement carefully. A solution to today's #haskell problem http://lpaste.net/112592
  • October 15th, 2014: Today's #haskell problem: grid placement http://lpaste.net/112606. Or as Neo says: "Whoa."
<object class="BLOGGER-youtube-video" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" data-thumbnail-src="https://ytimg.googleusercontent.com/vi/WFNEgdwjEhs/0.jpg" height="266" width="320"><param name="movie" value="https://youtube.googleapis.com/v/WFNEgdwjEhs&amp;source=uds"/><param name="bgcolor" value="#FFFFFF"/><param name="allowFullScreen" value="true"/><embed allowfullscreen="true" height="266" src="https://youtube.googleapis.com/v/WFNEgdwjEhs&amp;source=uds" type="application/x-shockwave-flash" width="320"></embed></object>


  • October 16th, 2014: An ... 'intelligence' test http://lpaste.net/112694 for today's #haskell problem. Intelligence test: answered. http://lpaste.net/112759 I had to melt my brain to answer it, however, so that happened.
  • October 17th, 2014: Friedman day was yesterday, http://lpaste.net/112707 but it's today's #haskell problem. Bonus: Friedman proofsno less! http://lpaste.net/112709 ... using Frege's logic ... but only if you want to ... The solution (including the bonus solution) for the Friedman-day problem posted at http://lpaste.net/112735  WITH FOR-LOOPS!
  • October 20th, 2014: O! Little Town of Milford! http://lpaste.net/112921 has a butcher, baker, and candlestick maker, but who is who? Today's #haskell problem. Okay, gag me with the sequence operator! BLEH! (I really should have gone relational calculus here! :/) A solution at http://lpaste.net/112954
  • October 21st, 2014: Se7en Little numbers ... okay, well, four of them, anyway, for today's #haskell problem http://lpaste.net/112972 Quantum nodes of scintillating thought http://lpaste.net/112996  A solution to today's #Haskell problem.
<object class="BLOGGER-youtube-video" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" data-thumbnail-src="https://ytimg.googleusercontent.com/vi/zsyjS_vJfkw/0.jpg" height="266" width="320"><param name="movie" value="https://youtube.googleapis.com/v/zsyjS_vJfkw&amp;source=uds"/><param name="bgcolor" value="#FFFFFF"/><param name="allowFullScreen" value="true"/><embed allowfullscreen="true" height="266" src="https://youtube.googleapis.com/v/zsyjS_vJfkw&amp;source=uds" type="application/x-shockwave-flash" width="320"></embed></object>
  • October 22nd, 2014: Word Numb3rs is today's #haskell puzzle (thanks to @BenVitale) 'AND' in your language of choice as you so choose. http://lpaste.net/113018 Hinglish-Vinglish is our response to this exercise.  http://lpaste.net/113045 "Fruitful." Yeah. Well, at least we got Data.Numeral.English http://lpaste.net/113037 out of it. SWEET!
  • October 23rd, 2014: Today's #haskell problem comes from http://projecteuler.net and is about ... well: Euler, himself! http://lpaste.net/113069 Well, if you wanted list of writer monads, you could've just asked for a list of writer monads http://lpaste.net/113084 
  • October 24th, 2014: Even odds is our #haskell problem today, thanks to @BenVitale http://lpaste.net/113141 A solution (actually two defined solutions) to @BenVitale even odds problem posted for today's #haskell problem http://lpaste.net/113167
I dub this coming week 'Kakuro week' for the theme of #haskell problems to solve (puzzle rendered using #haskell)
  • October 27th, 2014: #kakuro-week: the empty slate is our step one for our #haskell problem(s) to solve today http://lpaste.net/113255


  • Then we have the...'filled'-slate as a solution to 'today's #haskell problems for #kakuro-week http://lpaste.net/113314 
  • October 28th, 2014: «On y va!» declaims Sgt. Johnson as he charges headlong into solving today's #haskell problem http://lpaste.net/113316 
  • And that's how a 'partial' cookie crumbles. Partially. A partial solution to yesterday's #haskell #kakuro problem http://lpaste.net/113397
  • October 29th, 2014: A magnificent clue for today's #haskell problem in this #kakuro-puzzle-themed week http://lpaste.net/113399
  • October 30th, 2014: So, what does the 'Su' mean? http://lpaste.net/113451 Today's #haskell puzzler is a sudoku-solver. That you wrote. DoIt-ToIt!
  • October 31st, 2014: Merry Christmas! No. Heurieusement anniversaire! Nope. TRICK OR TREAT! Ya, that's the stuff! http://lpaste.net/113524 Today's #haskell problem
Categories: Offsite Blogs

Nomyx (Beta 7): win 10000 Blings!

haskell-cafe - Mon, 11/03/2014 - 12:12am
Join us on Nomyx: www.nomyx.net It's a unique game where you can change the rules of the game, while playing it. Log in, and you'll understand better what the title means (check rule 44 proposed by me in the game)! Cheers, Corentin _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe< at >haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Categories: Offsite Discussion

Presumably easy question regarding types

Haskell on Reddit - Sun, 11/02/2014 - 7:19pm

Hello! Could someone please explain the following? Given this function... (Edited for a typo - thanks guys!)

flip :: (a -> b -> c) -> b -> a -> c flip f x y = f y x

Why is this true?

x :: b

I thought x would be a? Isn't f :: a -> b -> c? So x is a function which takes a as an argument and returns a function fx which takes b as an argument and returns c? I am so confused and it's being a huge impediment to my getting further into this cool language!

Thanks very much for your help. Sorry this is a very elementary question.

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

Help with nix and ghc-mod ?

Haskell on Reddit - Sun, 11/02/2014 - 5:12pm

I was not sure if I should rather post this here or over at /r/nixos but I think quite a few of you are using nix and/or nixos anyhow. This weekend I tried to get started with using nix on my ubuntu laptop and thanks to some friendy guys in #nixos and some blog posts I did get some basic setup running. The problem I am facing right now is with ghc-mod. I cannot get it to work and the errors are absolutely cryptic to me:

[nix-shell : ~/Development/haskell/hoobuddy]$ ghc-mod /tmp/gilligan/ghc-mod-gilligan-Development-haskell-hoobuddy27622/package.cache: getFileStatus: does not exist No Such file or directory)

This is my default.nix for this project, the hoobuddy.cabal file was created using cabal2nix. Googling around I did not find much apart from this and I am not sure if this is actually related. Has anyone else here had similar problems or could give me a tip what I need to do to fix this? Any help would be appreciated ;)

Thanks.

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

Neil Mitchell: November talks

Planet Haskell - Sun, 11/02/2014 - 3:31pm

Summary: I'll be talking at CodeMesh 2014 on 5th November and FP Days on 20th November.

I am giving two talks in London this month:

CodeMesh 2014 - Gluing Things Together with Haskell, 5th Nov

I'll be talking about how you can use Haskell as the glue language in a project, instead of something like Bash. In particular, I'll cover Shake, NSIS and Bake. The abstract reads:

A large software project is more than just the code that goes into a release, in particular you need lots of glue code to put everything together - including build systems, test harnesses, installer generators etc. While the choice of language for the project is often a carefully considered decision, more often than not the glue code consists of shell scripts and Makefiles. But just as functional programming provides a better way to write the project, it also provides a better way to write the glue code. This talk covers some of the technologies and approaches we use at Standard Chartered to glue together the quant library. In particular, we'll focus on the build system where we replaced 10,000 lines of Makefiles with 1,000 lines of Haskell which builds the project twice as fast. We'll also look at how to test programs using Haskell, how to replace ancillary shell scripts with Haskell, and how to use Haskell to generate installers.

FP Days 2014 - Building stuff with Shake, 20th Nov

I'll be giving a tutorial on building stuff with Shake. It's going to be less sales pitch, more how you structure a build system, and how you use Shake effectively. The abstract reads:

Build systems are a key part of any large software project, relied upon by both developers and release processes. It's important that the build system is understandable, reliable and fast. This talk introduces the Shake build system which is intended to help meet those goals. Users of Shake write a Haskell program which makes heavy use of the Shake library, while still allowing the full power of Haskell to be used. The Shake library provides powerful dependency features along with useful extras (profiling, debugging, command line handling). This tutorial aims to help you learn how to think about writing build systems, and how to make those thoughts concrete in Shake.

Categories: Offsite Blogs

Nomyx: win 10000 Blings!

Haskell on Reddit - Sun, 11/02/2014 - 1:43pm

Join us on Nomyx: www.nomyx.net
It's a unique game where you can change the rules of the game, while playing it.
Log in, and you'll understand better what the title means (check rule 44 proposed by me in the game)!

submitted by kaukau
[link] [8 comments]
Categories: Incoming News

Discussion: Arities of <*> and *> for Monad instances

libraries list - Sun, 11/02/2014 - 11:29am
http://hackage.haskell.org/package/base-4.7.0.1/docs/Control-Applicative.html says that The other methods have the following default definitions, which may be overridden with equivalent specialized implementations: u *> v = pure (const id) <*> u <*> v and If f is also a Monad, it should satisfy ... (<*>) = ap The (potential) trouble is that these have higher arities than is always natural. For example, it would seem reasonable to say (<*>) Just f = fmap f (<*>) Nothing = const Nothing and to replace the default definition of (*>) like so: (*>) a1 = (<*>) (id <$ a1) but these are not strictly equivalent because they have arity 1 instead of arity 2. Would such definitions be be better in some cases? If so, should we weaken the rules a bit? _______________________________________________ Libraries mailing list Libraries< at >haskell.org http://www.haskell.org/mailman/listinfo/libraries
Categories: Offsite Discussion

Help With Bindings

Haskell on Reddit - Sun, 11/02/2014 - 9:25am

I'm relatively new to Haskell and am trying to implement nim, I have written all the code but cannot for the life of me work out the type bindings, the code is long but I was hoping someone could explain to me what the bindings for each function are and why? Thanks.

nim :: ? nim = do putStrLn "Enter first player's name!" n1 <- getLine putStrLn "Enter second player's name!" n2 <- getLine putStrLn "Enter pile amounts, enter 0 to stop adding piles." ps <- getPiles [] w <- play n1 n2 ps f <- (w ++ " has won!") return f play :: ? play n1 n2 ps = do p <- (n1 ++ "'s Turn! \n") putStrLn p displayGame ps m <- getMove nps <- (takeAway ps (getFst m) (getSnd m)) if won ps == True then return n1 else play n2 n1 nps getPiles :: ? getPiles xs = do putStr "Enter amount in next pile : " x <- (read getLine) if x == 0 then do xs ++ [x] getPiles xs else xs getFst :: (Int,Int) -> Int getFst (x,_) = x getSnd :: (Int,Int) -> Int getSnd (_,x) = x

The bindings for other functions used are -

won :: [Int] -> Bool takeAway :: [Int] -> Int -> Int -> [Int] getMove :: IO (Int,Int) displayGame :: [Int] -> IO ()

I realize that this might be allot to ask but I have hit a dead end and my "teammates" are of no help.

submitted by con7con
[link] [22 comments]
Categories: Incoming News

Haskell on the JVM?

Haskell on Reddit - Sun, 11/02/2014 - 7:16am

This has been asked before here and here. It would be great to have a JVM backend for Haskell. Why is there no serious effort from the Haskell community to implement it?

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

runStateT :: StateT s a -> s -> m (a, s)

Haskell on Reddit - Sat, 11/01/2014 - 9:21pm

Anyone else feel that runStateT and friends (execState, runReader etc) would be better flipped? I always find myself writing flip runStateT, because I never need to parameterise the state variable and it's convenient to use multiline do syntax for the action. Just curious.

submitted by scottansan
[link] [18 comments]
Categories: Incoming News

How would you simplify this? Guards prevent better pattern matching. :(

Haskell on Reddit - Sat, 11/01/2014 - 2:49pm

Haskell people, any ideas on how I can refactor this code? : http://tinyurl.com/l38hdp3 I use a lot of fromJust and isNothing, which looks horrible, but I cannot pattern match on them because I'm using guards. Since I have a lot of guards that are kinda irregular, using nested ifs seemed worse. Not to mention that the order of the guards matters. I don't see how to pattern match the Maybe values. The current version works but it's ugly. I wonder what you'd do. (By the way, there are a lot of tests in the repo that you can run. The tests cover the requirements of Turkish syllabification) Thanks!

submitted by wavesofthought
[link] [14 comments]
Categories: Incoming News