Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy isn't Haskell Partial Application Working?
    text
    copied!<p>My work in Haskell comes in the form of re-working .Net F# projects in Haskell for the fun of it.</p> <p>I'm parsing a regular Windows configuration file--one key/value pair per line, key separated from value by <code>=</code>. This file is very simple and straight-forward, which allows my parsing code to be simple and straight-forward, which I like.</p> <p>My question is why partial application is not working on the last line of code below. It's obviously working in prior lines and other functions.</p> <pre><code>module Configuration (Config (..), load) where import Data.Char (isSpace) import Data.List (isPrefixOf) data Config = Config { aliases :: [String] , headers :: [String] } -- This is a naive implementation. I can't decide if I like it better than -- trim = unpack . strip . pack. trim :: String -&gt; String trim = reverse . dropSpaces . reverse . dropSpaces dropSpaces :: String -&gt; String dropSpaces = dropWhile isSpace split _ [] = [] split c cs = [takeWhile (/= c) cs] ++ split c (tail' $ dropWhile (/= c) cs) where tail' [] = [] tail' (x:xs) = xs load :: String -&gt; Config load text = let ss = lines text hs = map getValue $ getLines "Header" ss as = split ',' $ getValue $ getLine "AliasList" ss in Config { aliases=as, headers=hs } where getLines p = filter (p `isPrefixOf`) getValue = trim . drop 1 . dropWhile (/= '=') getLine = head . getLines -- Why isn't partial application working here? </code></pre> <p>The error I'm getting follows:</p> <pre><code>Configuration.hs:30:29: Couldn't match expected type `[c0]' with actual type `[[a0]] -&gt; [[a0]]' Expected type: [a0] -&gt; [c0] Actual type: [a0] -&gt; [[a0]] -&gt; [[a0]] In the second argument of `(.)', namely `getLines' In the expression: head . getLines </code></pre> <p>Thanks!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload