From borgauf at gmail.com Thu Mar 2 21:34:26 2017 From: borgauf at gmail.com (Lawrence Bottorff) Date: Thu, 2 Mar 2017 16:34:26 -0500 Subject: [Haskell-beginners] Latest ghci on Ubuntu 16.10? Message-ID: I'm on Ubuntu 16.10 and I've followed this , but now I have ghci 7.10.3, which still needs the the "let" in front of every function for use in places like Emacs org-mode's babel. Here's an example of what I have to do in org-mode to get it to run: #+begin_src haskell :set +m let doubleSmallNumber4 x = if x > 0 then x else x*2 doubleSmallNumber4 42 #+end_src I've heard that an 8.+ version of ghci eliminates this issue. Is this true? If so, how can I upgrade my "stack." LB -------------- next part -------------- An HTML attachment was scrubbed... URL: From shaegis at gmail.com Fri Mar 3 23:57:02 2017 From: shaegis at gmail.com (S. H. Aegis) Date: Sat, 4 Mar 2017 08:57:02 +0900 Subject: [Haskell-beginners] Execution error in using text-icu on windows Message-ID: Hi. I worte some code. and fixed some errors with the help of good persons. Now, this utility works properly in Stack environment. How can I install this utility in other computer? This utility use text-icu and I coded this utility on windows. Of course, I want to work this utility on other windows OS. I copied %stackPath%\.stack-work\install\~\bin\samCheceker-exe.exe to some other folder, and execution through CMD. But I got error message that says "libicuuc57.dll dose not exist. so program can't start. please re-install the program." I copied libicuuc57.dll, and so... as like programming newbees, but failed. "stack install" command was the same result. How can I install the Executable File to other windows system? Thank you. Sincerely, S. Chang. ------------------ samChecker.cabal ------------------ name: samChecker3 version: 0.1.0.0 -- synopsis: -- description: homepage: https://github.com/githubuser/samChecker3#readme license: BSD3 license-file: LICENSE author: Author name here maintainer: example at example.com copyright: 2017 Author name here category: Web build-type: Simple extra-source-files: README.md cabal-version: >=1.10 library hs-source-dirs: src exposed-modules: Lib build-depends: base >= 4.7 && < 5 , text , text-icu , bytestring , regex-tdfa default-language: Haskell2010 executable samChecker3-exe hs-source-dirs: app main-is: Main.hs ghc-options: -threaded -rtsopts -with-rtsopts=-N build-depends: base , samChecker3 , text , text-icu , bytestring , regex-tdfa default-language: Haskell2010 test-suite samChecker3-test type: exitcode-stdio-1.0 hs-source-dirs: test main-is: Spec.hs build-depends: base , samChecker3 ghc-options: -threaded -rtsopts -with-rtsopts=-N default-language: Haskell2010 source-repository head type: git location: https://github.com/githubuser/samChecker3 ----------- Main.hs ----------- module Main where import Lib import System.Environment --import System.FilePath.Windows import Data.Text.ICU.Convert -- There is Codec.Text.IConv, too. import qualified Data.Text as T import qualified Data.Text.IO as TIO import qualified Data.ByteString as BS main :: IO () main = do args <- getArgs -- 1st=SAM 2nd=csv conv <- open "MS949" Nothing -- byteSAM :: ByteString --byteSAM <- BS.readFile "C:\\Users\\shaeg\\Documents\\Haskell\\samChecker3\\BoHom.dat" byteSAM <- BS.readFile (args !! 0) -- byteRxDxData :: ByteString --byteRxDxData <- BS.readFile "C:\\Users\\shaeg\\Documents\\Haskell\\samChecker3\\RxDxData.csv" byteRxDxData <- BS.readFile (args !! 1) TIO.putStrLn $ T.concat $ checkRxDxSAM (toUnicode conv byteRxDxData) (toUnicode conv byteSAM) ----------- Lib.hs ----------- module Lib -- ( readSAM -- , readCSV -- , checkRxDxSAM -- ) where where import Data.Text as T import Data.Text.IO as TIO import Data.Text.ICU.Convert import qualified Data.ByteString as BS import Text.Regex.TDFA import Data.Text.ICU as I import Prelude hiding (take, drop, map, lines) type RowSAM = Text type SAM = [Text] type Case = Text type RowRxDx = Text type RxDx = [Text] type RxDxList = [[Text]] type Rx = Text type Dx = Text type MediName = Text type Message = Text type ErrorMessage = Text type Date = Text type PtName = Text checkRxDxSAM :: RowRxDx -> RowSAM -> [ErrorMessage] checkRxDxSAM rxDx sam = [pickupError r s | r <- (makeTuple rxDx), s <- makeSamData sam] makeSamData :: RowSAM -> SAM makeSamData sam = splitIntoCase sam makeTuple :: RowRxDx -> [(Rx, Dx, MediName)] makeTuple rxDx = zip3 (makeRxList rxDx) (makeDxList rxDx) (makeMediNameList rxDx) makeMediNameList :: RowRxDx -> [MediName] makeMediNameList rxDx = fmap pickupMediName $ makeRxDxList rxDx makeDxList :: RowRxDx -> [Dx] makeDxList rxDx = fmap pickupDx $ makeRxDxList rxDx makeRxList :: RowRxDx -> [Rx] makeRxList rxDx = fmap pickupRx $ makeRxDxList rxDx makeRxDxList :: RowRxDx -> RxDxList makeRxDxList rowRxDx = fmap f (lines rowRxDx) where f :: Text -> [Text] f x = splitOn (pack ",") x pickupError :: (Rx, Dx, Message) -> Case -> ErrorMessage pickupError (rxCode, dxCode, errMsg) ptCase = case isErrorRxDx rxCode dxCode ptCase of --True -> append (pickupCaseDate ptCase) $ append (pack " ") $ append (pickupPtName ptCase) $ append (pack " Omit ") $ append dxCode $ append (pack " for ") errMsg True -> append (pickupCaseDate ptCase) $ append (pack " ") $ append (pickupPtName ptCase) $ append (pack " Omit ") $ append dxCode $ append (pack " for ") $ append errMsg (pack "\n") False -> T.empty pickupMediName :: RxDx -> MediName pickupMediName rxDx = rxDx !! 0 pickupDx :: RxDx -> Dx pickupDx rxDx = rxDx !! 2 pickupRx :: RxDx -> Rx pickupRx rxDx = rxDx !! 1 pickupPtName :: Case -> PtName pickupPtName ptCase = take 3 $ drop 45 ptCase pickupCaseDate :: Case -> Date pickupCaseDate ptCase = take 8 $ drop (348 + 2) ptCase isErrorRxDx :: Rx -> Dx -> Case -> Bool isErrorRxDx rxCode dxCode ptCase = case isExistRx rxCode ptCase of True -> if (isExistDx dxCode ptCase) then False else True False -> False isExistDx :: Dx -> Case -> Bool --isExistDx dxCode ptCase = (unpack ptCase) =~ (unpack dxCode) isExistDx dxCode ptCase = case (I.find (regex [] dxCode) ptCase) of Just x -> True Nothing -> False isExistRx :: Rx -> Case -> Bool isExistRx rxCode ptCase = rxCode `isInfixOf` ptCase splitIntoCase :: RowSAM -> SAM splitIntoCase = splitOn $ pack "AH021" --readCSV :: IO Text --readCSV = pack <$> readFile "/Users/shaegis/Documents/Haskell/samChecker3/RxDxData.csv" --readSAM:: IO Text --readSAM = pack <$> readFile "/Users/shaegis/Documents/Haskell/samChecker3/BoHomUTF8.dat" -------------- next part -------------- An HTML attachment was scrubbed... URL: From fa-ml at ariis.it Sat Mar 4 07:12:15 2017 From: fa-ml at ariis.it (Francesco Ariis) Date: Sat, 4 Mar 2017 08:12:15 +0100 Subject: [Haskell-beginners] Execution error in using text-icu on windows In-Reply-To: References: Message-ID: <20170304071215.GA1472@casa.casa> On Sat, Mar 04, 2017 at 08:57:02AM +0900, S. H. Aegis wrote: > Hi. > > I worte some code. and fixed some errors with the help of good persons. > Now, this utility works properly in Stack environment. > How can I install this utility in other computer? > This utility use text-icu and I coded this utility on windows. Of course, I > want to work this utility on other windows OS. > > I copied %stackPath%\.stack-work\install\~\bin\samCheceker-exe.exe to some > other folder, and execution through CMD. > But I got error message that says "libicuuc57.dll dose not exist. so > program can't start. please re-install the program." > I copied libicuuc57.dll, and so... as like programming newbees, but failed. > "stack install" command was the same result. > > How can I install the Executable File to other windows system? Hello, maybe you can try compiling with: stack build --ghc-options '-static -optl-static' (and stack clean before, probably). I am not a windows or stack user, so this I cannot test this. Report back and let us know if it worked or not. From shaegis at gmail.com Sat Mar 4 13:05:27 2017 From: shaegis at gmail.com (S. H. Aegis) Date: Sat, 4 Mar 2017 22:05:27 +0900 Subject: [Haskell-beginners] Execution error in using text-icu on windows In-Reply-To: <20170304071215.GA1472@casa.casa> References: <20170304071215.GA1472@casa.casa> Message-ID: Thank you so much, Francesco Ariis. Thanks to your help, I stepped foreword. But I got following error message. I googled this error message & try to fix this, but faild. How can I fix or get info. for this error message? Thank you so much. C:\Users\shaeg\Documents\Haskell\samChecker3> stack build --ghc-options="-static -optl-static" Warning: File listed in samChecker3.cabal file does not exist: README.md samChecker3-0.1.0.0: unregistering (local file changes: app\Main.hs samChecker3.cabal src\Lib.hs test\Spec.hs) samChecker3-0.1.0.0: configure (lib + exe) Configuring samChecker3-0.1.0.0... samChecker3-0.1.0.0: build (lib + exe) Preprocessing library samChecker3-0.1.0.0... [1 of 1] Compiling Lib ( src\Lib.hs, .stack-work\dist\ca59d0ab\build\Lib.o ) Preprocessing executable 'samChecker3-exe' for samChecker3-0.1.0.0... [1 of 1] Compiling Main ( app\Main.hs, .stack-work\dist\ca59d0ab\build\samChecker3-exe\samChecker3-exe-tmp\Main.o ) Linking .stack-work\dist\ca59d0ab\build\samChecker3-exe\samChecker3-exe.exe ... C:/Users/shaeg/AppData/Local/Programs/stack/x86_64-windows/ghc-8.0.2/mingw/bin/ld.exe: cannot find -licuuc C:/Users/shaeg/AppData/Local/Programs/stack/x86_64-windows/ghc-8.0.2/mingw/bin/ld.exe: cannot find -licuin C:/Users/shaeg/AppData/Local/Programs/stack/x86_64-windows/ghc-8.0.2/mingw/bin/ld.exe: cannot find -licudt collect2.exe: error: ld returned 1 exit status `gcc.exe' failed in phase `Linker'. (Exit code: 1) Warning: File listed in samChecker3.cabal file does not exist: README.md -- While building package samChecker3-0.1.0.0 using: C:\sr\setup-exe-cache\x86_64-windows\Cabal-simple_Z6RU0evB_1.24.2.0_ghc-8.0.2.exe --builddir=.stack-work\dist\ca59d0ab build lib:samChecker3 exe:samChecker3-exe --ghc-options " -ddump-hi -ddump-to-file" Process exited with code: ExitFailure 1 2017-03-04 16:12 GMT+09:00 Francesco Ariis : > On Sat, Mar 04, 2017 at 08:57:02AM +0900, S. H. Aegis wrote: > > Hi. > > > > I worte some code. and fixed some errors with the help of good persons. > > Now, this utility works properly in Stack environment. > > How can I install this utility in other computer? > > This utility use text-icu and I coded this utility on windows. Of > course, I > > want to work this utility on other windows OS. > > > > I copied %stackPath%\.stack-work\install\~\bin\samCheceker-exe.exe to > some > > other folder, and execution through CMD. > > But I got error message that says "libicuuc57.dll dose not exist. so > > program can't start. please re-install the program." > > I copied libicuuc57.dll, and so... as like programming newbees, but > failed. > > "stack install" command was the same result. > > > > How can I install the Executable File to other windows system? > > Hello, maybe you can try compiling with: > > stack build --ghc-options '-static -optl-static' > > (and stack clean before, probably). > > I am not a windows or stack user, so this I cannot test this. Report > back and let us know if it worked or not. > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > -- Sok Ha, CHANG Dr. Chang's Clinic. #203. 503-23. AmSa-Dong, GangDong-Gu, Seoul. Tel: +82-2-442-7585 -------------- next part -------------- An HTML attachment was scrubbed... URL: From fa-ml at ariis.it Sat Mar 4 14:10:03 2017 From: fa-ml at ariis.it (Francesco Ariis) Date: Sat, 4 Mar 2017 15:10:03 +0100 Subject: [Haskell-beginners] Execution error in using text-icu on windows In-Reply-To: References: <20170304071215.GA1472@casa.casa> Message-ID: <20170304141003.GA9507@casa.casa> On Sat, Mar 04, 2017 at 10:05:27PM +0900, S. H. Aegis wrote: > Thank you so much, Francesco Ariis. > Thanks to your help, I stepped foreword. > > But I got following error message. I googled this error message & try to > fix this, but faild. > How can I fix or get info. for this error message? > Thank you so much. > > [...] > > Linking .stack-work\dist\ca59d0ab\build\samChecker3-exe\samChecker3-exe.exe > ... > C:/Users/shaeg/AppData/Local/Programs/stack/x86_64-windows/ghc-8.0.2/mingw/bin/ld.exe: > cannot find -licuuc > C:/Users/shaeg/AppData/Local/Programs/stack/x86_64-windows/ghc-8.0.2/mingw/bin/ld.exe: > cannot find -licuin > C:/Users/shaeg/AppData/Local/Programs/stack/x86_64-windows/ghc-8.0.2/mingw/bin/ld.exe: > cannot find -licudt > collect2.exe: error: ld returned 1 exit status > `gcc.exe' failed in phase `Linker'. (Exit code: 1) > > [...] Argh, that's the linker acting up. I haven't been using windows in 10 years, but is LIBRARY_PATH defined on your system? And if so, where is it pointing? Its value should be where the .a/.lib files are located (in your particular example, icudt.lib, etc.). Again, not a windows nor a stack user, so maybe you want to wait for more answers and/or ask on haskell-stack at googlegroups.com too -F From shaegis at gmail.com Sat Mar 4 15:24:32 2017 From: shaegis at gmail.com (S. H. Aegis) Date: Sun, 5 Mar 2017 00:24:32 +0900 Subject: [Haskell-beginners] Execution error in using text-icu on windows In-Reply-To: <20170304141003.GA9507@casa.casa> References: <20170304071215.GA1472@casa.casa> <20170304141003.GA9507@casa.casa> Message-ID: Thank you so much, Francesco Ariis. [stack path] results extra-include-dirs: C:\Users\shaeg\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include extra-library-dirs: C:\Users\shaeg\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\lib According to first error message(libicuuc57.dll dose not exist. so program can't start. please re-install the program.), I find the path for libicuuc57.dll, and re-set the extra-library-dirs. C:\Users\shaeg\Documents\Haskell\samChecker3>stack build --extra-lib-dirs=C:\Users\shaeg\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\bin --ghc-options="-static -optl-static" But got the same result. How can I fix this? Thank you. Sincerely, S. Chang. Here is my stack path. C:\Users\shaeg\Documents\Haskell\samChecker3>stack path stack-root: C:\sr project-root: C:\Users\shaeg\Documents\Haskell\samChecker3 config-location: C:\Users\shaeg\Documents\Haskell\samChecker3\stack.yaml bin-path: .;C:\sr\snapshots\7dd4ddea\bin;C:\Users\shaeg\AppData\Local\Programs\stack\x86_64-windows\ghc-8.0.2\bin;C:\Users\shaeg\AppData\Local\Programs\stack\x86_64-windows\ghc-8.0.2\mingw\bin;C:\Users\shaeg\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\bin;C:\Users\shaeg\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\usr\bin;C:\Users\shaeg\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\usr\local\bin;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\IntelSGXPSW\bin\x64\Release\;C:\Program Files\Intel\IntelSGXPSW\bin\win32\Release\;c:\Program Files\Intel\WiFi\bin\;c:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files\Hewlett-Packard\SimplePass\;C:\Users\shaeg\AppData\Roaming\local\bin;C:\Users\shaeg\AppData\Local\Microsoft\WindowsApps programs: C:\Users\shaeg\AppData\Local\Programs\stack\x86_64-windows compiler-exe: C:\Users\shaeg\AppData\Local\Programs\stack\x86_64-windows\ghc-8.0.2\bin\ghc.EXE compiler-bin: C:\Users\shaeg\AppData\Local\Programs\stack\x86_64-windows\ghc-8.0.2\bin local-bin: C:\Users\shaeg\AppData\Roaming\local\bin extra-include-dirs: C:\Users\shaeg\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include extra-library-dirs: C:\Users\shaeg\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\lib snapshot-pkg-db: C:\sr\snapshots\7dd4ddea\pkgdb local-pkg-db: C:\Users\shaeg\Documents\Haskell\samChecker3\.stack-work\install\02136e14\pkgdb global-pkg-db: C:\Users\shaeg\AppData\Local\Programs\stack\x86_64-windows\ghc-8.0.2\lib\package.conf.d ghc-package-path: C:\Users\shaeg\Documents\Haskell\samChecker3\.stack-work\install\02136e14\pkgdb;C:\sr\snapshots\7dd4ddea\pkgdb;C:\Users\shaeg\AppData\Local\Programs\stack\x86_64-windows\ghc-8.0.2\lib\package.conf.d snapshot-install-root: C:\sr\snapshots\7dd4ddea local-install-root: C:\Users\shaeg\Documents\Haskell\samChecker3\.stack-work\install\02136e14 snapshot-doc-root: C:\sr\snapshots\7dd4ddea\doc local-doc-root: C:\Users\shaeg\Documents\Haskell\samChecker3\.stack-work\install\02136e14\doc dist-dir: .stack-work\dist\ca59d0ab local-hpc-root: C:\Users\shaeg\Documents\Haskell\samChecker3\.stack-work\install\02136e14\hpc local-bin-path: C:\Users\shaeg\AppData\Roaming\local\bin ghc-paths: C:\Users\shaeg\AppData\Local\Programs\stack\x86_64-windows 2017-03-04 23:10 GMT+09:00 Francesco Ariis : > On Sat, Mar 04, 2017 at 10:05:27PM +0900, S. H. Aegis wrote: > > Thank you so much, Francesco Ariis. > > Thanks to your help, I stepped foreword. > > > > But I got following error message. I googled this error message & try to > > fix this, but faild. > > How can I fix or get info. for this error message? > > Thank you so much. > > > > [...] > > > > Linking .stack-work\dist\ca59d0ab\build\samChecker3-exe\ > samChecker3-exe.exe > > ... > > C:/Users/shaeg/AppData/Local/Programs/stack/x86_64-windows/ > ghc-8.0.2/mingw/bin/ld.exe: > > cannot find -licuuc > > C:/Users/shaeg/AppData/Local/Programs/stack/x86_64-windows/ > ghc-8.0.2/mingw/bin/ld.exe: > > cannot find -licuin > > C:/Users/shaeg/AppData/Local/Programs/stack/x86_64-windows/ > ghc-8.0.2/mingw/bin/ld.exe: > > cannot find -licudt > > collect2.exe: error: ld returned 1 exit status > > `gcc.exe' failed in phase `Linker'. (Exit code: 1) > > > > [...] > > Argh, that's the linker acting up. > I haven't been using windows in 10 years, but is LIBRARY_PATH defined > on your system? And if so, where is it pointing? > Its value should be where the .a/.lib files are located (in your > particular example, icudt.lib, etc.). > > Again, not a windows nor a stack user, so maybe you want to wait > for more answers and/or ask on haskell-stack at googlegroups.com too > -F > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > -------------- next part -------------- An HTML attachment was scrubbed... URL: From wallmarkets at gmail.com Wed Mar 15 04:37:21 2017 From: wallmarkets at gmail.com (tscosj tscosj) Date: Wed, 15 Mar 2017 13:37:21 +0900 Subject: [Haskell-beginners] Beginners Digest, Vol 104, Issue 16 In-Reply-To: References: Message-ID: [image: Inline image 1] "Problem Opening Wizard" I've Eclipse "Version: Neon.2 Release (4.6.2) Build id: 20161208-0600" installed on macOS El Capitan 10.11.6. ​"The selected wizard could not be started. Plug-in net.sf.eclipsefp.haskell.ui was unable to load class net.sf.eclipsefp.haskell.ui.wizards.NewHaskellProjectWizard. An error occurred while automatically activating bundle net.sf.eclipsefp.haskell.ui (482)."​ Albert. Anyone has the same problem and solved it? Thanks. On Thu, Feb 23, 2017 at 1:10 AM, wrote: > Send Beginners mailing list submissions to > beginners at haskell.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > or, via email, send a message with subject or body 'help' to > beginners-request at haskell.org > > You can reach the person managing the list at > beginners-owner at haskell.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Beginners digest..." > > > Today's Topics: > > 1. Re: Type error when using splitOn function. (Francesco Ariis) > 2. Re: Type error when using splitOn function. (S. H. Aegis) > 3. How to link two Types (PICCA Frederic-Emmanuel) > 4. Re: How to link two Types (David McBride) > 5. Re: How to link two Types (PICCA Frederic-Emmanuel) > 6. Re: How to link two Types (David McBride) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Wed, 22 Feb 2017 14:31:16 +0100 > From: Francesco Ariis > To: beginners at haskell.org > Subject: Re: [Haskell-beginners] Type error when using splitOn > function. > Message-ID: <20170222133116.GA14860 at casa.casa> > Content-Type: text/plain; charset=us-ascii > > On Wed, Feb 22, 2017 at 09:02:22PM +0900, S. H. Aegis wrote: > > Thank you so much. > > > > --makeRxDxList :: Functor f => f Text -> f [Text] > > Above signature comes from ghci using command :t > > My intention is > > makeRxDxList :: Text -> [[Text]] > > but, I got error, and try several times and below codes pass a complier. > > makeRxDxList rowRxDx = fmap (\x -> splitOn (pack ",") x) rowRxDx -- This > > code pass a compile. > > and then, I run ghci, type :t, and got below signature. > > makeRxDxList :: Functor f => f Text -> f [Text] > > > > Your kind answer says, I cannot help using fmap. right? ^^; > > Thanks again. > > Then this: > > makeRxDxList :: Text -> [[Text]] > makeRxDxList rowRxDx = fmap f (lines rowRxDx) > -- you imported Prelude hiding map, so we will use fmap > where > f :: Text -> [Text] > f x = splitOn (pack ",") x > > should do (at least it typechecks). > > GHC errors may not have the prettiest formatting ever, but they are > very useful, the most important bits being line & column of the offending > expression plus the "expected this but got that" part; get acquainted > with them! > > > > ------------------------------ > > Message: 2 > Date: Wed, 22 Feb 2017 22:41:10 +0900 > From: "S. H. Aegis" > To: The Haskell-Beginners Mailing List - Discussion of primarily > beginner-level topics related to Haskell > Subject: Re: [Haskell-beginners] Type error when using splitOn > function. > Message-ID: > gmail.com> > Content-Type: text/plain; charset="utf-8" > > It works !!! (^O^) > Thank you so much. > > Have a nice day~! > > 2017-02-22 22:31 GMT+09:00 Francesco Ariis : > > > On Wed, Feb 22, 2017 at 09:02:22PM +0900, S. H. Aegis wrote: > > > Thank you so much. > > > > > > --makeRxDxList :: Functor f => f Text -> f [Text] > > > Above signature comes from ghci using command :t > > > My intention is > > > makeRxDxList :: Text -> [[Text]] > > > but, I got error, and try several times and below codes pass a > complier. > > > makeRxDxList rowRxDx = fmap (\x -> splitOn (pack ",") x) rowRxDx -- > This > > > code pass a compile. > > > and then, I run ghci, type :t, and got below signature. > > > makeRxDxList :: Functor f => f Text -> f [Text] > > > > > > Your kind answer says, I cannot help using fmap. right? ^^; > > > Thanks again. > > > > Then this: > > > > makeRxDxList :: Text -> [[Text]] > > makeRxDxList rowRxDx = fmap f (lines rowRxDx) > > -- you imported Prelude hiding map, so we will use fmap > > where > > f :: Text -> [Text] > > f x = splitOn (pack ",") x > > > > should do (at least it typechecks). > > > > GHC errors may not have the prettiest formatting ever, but they are > > very useful, the most important bits being line & column of the offending > > expression plus the "expected this but got that" part; get acquainted > > with them! > > > > _______________________________________________ > > Beginners mailing list > > Beginners at haskell.org > > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > > > > > -- > Sok Ha, CHANG > Dr. Chang's Clinic. #203. 503-23. AmSa-Dong, GangDong-Gu, Seoul. > Tel: +82-2-442-7585 > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: attachments/20170222/0d194b9d/attachment-0001.html> > > ------------------------------ > > Message: 3 > Date: Wed, 22 Feb 2017 15:27:39 +0000 > From: PICCA Frederic-Emmanuel > > To: "Beginners at haskell.org" > Subject: [Haskell-beginners] How to link two Types > Message-ID: > synchrotron-soleil.fr> > > Content-Type: text/plain; charset="us-ascii" > > Hello, I wrote this code > > data DataFrameH5 a > = DataFrameH5 > (Nxs a) -- Nexus file > (DataSource H5) -- gamma > (DataSource H5) -- delta > (DataSource H5) -- wavelength > PoniGenerator -- ponie generator > > class Frame t a where > len :: t -> IO (Maybe Int) > row :: t -> Int -> MaybeT IO (DifTomoFrame a DIM1) > > instance Frame (DataFrameH5 DataFrameH5Path) DataFrameH5Path where > len (DataFrameH5 _ _ (DataSourceH5 _ d) _ _) = lenH5Dataspace d > > row d@(DataFrameH5 nxs' g d' w ponigen) idx = do > n <- lift $ len d > let eof = fromJust n - 1 == idx > let mu = 0.0 > let komega = 0.0 > let kappa = 0.0 > let kphi = 0.0 > gamma <- g `atIndex'` (ix1 0) > delta <- d' `atIndex'` (ix1 idx) > wavelength <- w `atIndex'` (ix1 0) > let source = Source (head wavelength *~ nano meter) > let positions = concat [mu, komega, kappa, kphi, gamma, delta] > -- print positions > let geometry = Geometry K6c source positions Nothing > let detector = ZeroD > m <- lift $ geometryDetectorRotationGet geometry detector > poniext <- lift $ ponigen (MyMatrix HklB m) idx > return $ DifTomoFrame { difTomoFrameNxs = nxs' > , difTomoFrameIdx = idx > , difTomoFrameEOF = eof > , difTomoFrameGeometry = geometry > , difTomoFramePoniExt = poniext > } > > has you can see my t type contains also the a reference to the a one > So when I create the instance, I need to write two times the > DataFrameH5Path > > I would like to know how to write the same class with only > > class Frame t where > len :: t -> IO (Maybe Int) > row :: t -> Int -> MaybeT IO (DifTomoFrame > DIM1) > > thanks for your help > > Frederic > > > ------------------------------ > > Message: 4 > Date: Wed, 22 Feb 2017 10:59:38 -0500 > From: David McBride > To: The Haskell-Beginners Mailing List - Discussion of primarily > beginner-level topics related to Haskell > Subject: Re: [Haskell-beginners] How to link two Types > Message-ID: > gmail.com> > Content-Type: text/plain; charset=UTF-8 > > Maybe TypeFamilies would work for you? I can only give you a > barebones outline of what it might look like. > > {-# LANGUAGE MultiParamTypeClasses, FlexibleInstances, TypeFamilies #-} > import Control.Monad.Trans.Maybe > > data DataFrameH5 a = DataFrameH5 > data DataFrameH5Path = DataFrameH5Path > > class Frame t where > type Key t > len :: t -> IO (Maybe Int) > row :: t -> Int -> MaybeT IO (Key t) > > instance Frame (DataFrameH5 a) where > type Key (DataFrameH5 a) = a > len DataFrameH5 = return . Just $ undefined > row DataFrameH5 idx = MaybeT $ do > return undefined > > On Wed, Feb 22, 2017 at 10:27 AM, PICCA Frederic-Emmanuel > wrote: > > Hello, I wrote this code > > > > data DataFrameH5 a > > = DataFrameH5 > > (Nxs a) -- Nexus file > > (DataSource H5) -- gamma > > (DataSource H5) -- delta > > (DataSource H5) -- wavelength > > PoniGenerator -- ponie generator > > > > class Frame t a where > > len :: t -> IO (Maybe Int) > > row :: t -> Int -> MaybeT IO (DifTomoFrame a DIM1) > > > > instance Frame (DataFrameH5 DataFrameH5Path) DataFrameH5Path where > > len (DataFrameH5 _ _ (DataSourceH5 _ d) _ _) = lenH5Dataspace d > > > > row d@(DataFrameH5 nxs' g d' w ponigen) idx = do > > n <- lift $ len d > > let eof = fromJust n - 1 == idx > > let mu = 0.0 > > let komega = 0.0 > > let kappa = 0.0 > > let kphi = 0.0 > > gamma <- g `atIndex'` (ix1 0) > > delta <- d' `atIndex'` (ix1 idx) > > wavelength <- w `atIndex'` (ix1 0) > > let source = Source (head wavelength *~ nano meter) > > let positions = concat [mu, komega, kappa, kphi, gamma, delta] > > -- print positions > > let geometry = Geometry K6c source positions Nothing > > let detector = ZeroD > > m <- lift $ geometryDetectorRotationGet geometry detector > > poniext <- lift $ ponigen (MyMatrix HklB m) idx > > return $ DifTomoFrame { difTomoFrameNxs = nxs' > > , difTomoFrameIdx = idx > > , difTomoFrameEOF = eof > > , difTomoFrameGeometry = geometry > > , difTomoFramePoniExt = poniext > > } > > > > has you can see my t type contains also the a reference to the a one > > So when I create the instance, I need to write two times the > DataFrameH5Path > > > > I would like to know how to write the same class with only > > > > class Frame t where > > len :: t -> IO (Maybe Int) > > row :: t -> Int -> MaybeT IO (DifTomoFrame t> DIM1) > > > > thanks for your help > > > > Frederic > > _______________________________________________ > > Beginners mailing list > > Beginners at haskell.org > > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > > ------------------------------ > > Message: 5 > Date: Wed, 22 Feb 2017 16:19:41 +0000 > From: PICCA Frederic-Emmanuel > > To: "The Haskell-Beginners Mailing List - Discussion of primarily > beginner-level topics related to Haskell" > Subject: Re: [Haskell-beginners] How to link two Types > Message-ID: > synchrotron-soleil.fr> > > Content-Type: text/plain; charset="us-ascii" > > Hello thanks, I will investigate, but I like this solution. > I can ad more type to a type family right ? > > > Is it possible with this type family to be able to link in the other way ? > > a -> t > > Cheers > > Fred > > ------------------------------ > > Message: 6 > Date: Wed, 22 Feb 2017 11:29:16 -0500 > From: David McBride > To: The Haskell-Beginners Mailing List - Discussion of primarily > beginner-level topics related to Haskell > Subject: Re: [Haskell-beginners] How to link two Types > Message-ID: > gmail.com> > Content-Type: text/plain; charset=UTF-8 > > It is hard to tell from your code what you intend, but it works > however you want it to, so long as it type checks. > > class Frame a where > type Whatever a > len :: Whatever a -> IO (Maybe Int) > row :: Whatever a -> MaybeT IO (DifTomoFrame a DIM1) > > instance Frame DataFrameH5Path where > type Whatever DataFrameH5Path = DataFrameH5 > len = undefined -- :: DataFrameH5 -> IO (Maybe Int) > row = undefined -- :: DataFrameH5 -> Int -> MaybeT (DifTomoFrame > DataFrameH5Path DIM1) > > > > On Wed, Feb 22, 2017 at 11:19 AM, PICCA Frederic-Emmanuel > wrote: > > Hello thanks, I will investigate, but I like this solution. > > I can ad more type to a type family right ? > > > > > > Is it possible with this type family to be able to link in the other way > ? > > > > a -> t > > > > Cheers > > > > Fred > > _______________________________________________ > > Beginners mailing list > > Beginners at haskell.org > > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > > ------------------------------ > > Subject: Digest Footer > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > > ------------------------------ > > End of Beginners Digest, Vol 104, Issue 16 > ****************************************** > -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: Screen Shot 2017-03-15 at 1.35.07 PM.png Type: image/png Size: 49287 bytes Desc: not available URL: From info at maximka.de Wed Mar 15 20:18:38 2017 From: info at maximka.de (info at maximka.de) Date: Wed, 15 Mar 2017 21:18:38 +0100 (CET) Subject: [Haskell-beginners] how does hgearman-client work? Message-ID: <214333272.46677.1489609119086@communicator.strato.de> An HTML attachment was scrubbed... URL: From toad3k at gmail.com Thu Mar 16 12:25:41 2017 From: toad3k at gmail.com (David McBride) Date: Thu, 16 Mar 2017 08:25:41 -0400 Subject: [Haskell-beginners] how does hgearman-client work? In-Reply-To: <214333272.46677.1489609119086@communicator.strato.de> References: <214333272.46677.1489609119086@communicator.strato.de> Message-ID: This library seems badly managed, but it does give you just enough to work with, if you know how to use monad transformers. someprocedure :: IO Bool someprocedure = do res <- connectGearman somebs somehost someport case res of Left e -> undefined Right client -> do (res, _) <- flip runStateT client $ do res <- submitJob somefunc somebs case res of Left e -> undefined Right bs -> do -- do something with bs return True return res If I were you I'd turn LambdaCase on to clean it up a bit, and do something like this. {-# LANGUAGE LambdaCase #-} ... someprocedure :: IO Bool someprocedure = do connectGearman somebs somehost someport >>= \case Left e -> return False Right client -> do flip evalStateT client $ do submitJob somefunc somebs >>= \case Left e -> return False Right bs -> do -- do something with bs return True On Wed, Mar 15, 2017 at 4:18 PM, wrote: > Hi, > I repeat my unanswered question in hope to find here some help: > > Unfortunately the package hgearman does not provide any test or example and > I can't work it out for myself how should be combined connectGearman and > submitJob to put a job to the gearman job server. > > The result of connectGearman is: > > ghci> conn <- connectGearman (B.pack "x") ("localhost"::HostName) > (4730::Port) > ghci> :t conn > conn :: Either GearmanError GearmanClient > > but submitJob uses private function submit which deals with StateT. So I can > only guess the result of connectGearman should be wrapped into S.StateT > GearmanClient IO without faintest idea how to do that. > > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > From info at maximka.de Thu Mar 16 13:34:25 2017 From: info at maximka.de (info at maximka.de) Date: Thu, 16 Mar 2017 14:34:25 +0100 (CET) Subject: [Haskell-beginners] how does hgearman-client work? In-Reply-To: References: <214333272.46677.1489609119086@communicator.strato.de> Message-ID: <2017570301.11767.1489671266264@communicator.strato.de> I'm really much obliged for your support, David. > This library seems badly managed, but it does give you just enough to > work with, if you know how to use monad transformers. It seems so. I tried to get some help by author at first: https://github.com/jperson/hgearman-client/issues/1 That's a reason why I'm working on PR to add some tests to the package. Cheers, Alexei > On 16 March 2017 at 13:25 David McBride wrote: > > > This library seems badly managed, but it does give you just enough to > work with, if you know how to use monad transformers. > > someprocedure :: IO Bool > someprocedure = do > res <- connectGearman somebs somehost someport > case res of > Left e -> undefined > Right client -> do > (res, _) <- flip runStateT client $ do > res <- submitJob somefunc somebs > case res of > Left e -> undefined > Right bs -> do > -- do something with bs > return True > return res > > If I were you I'd turn LambdaCase on to clean it up a bit, and do > something like this. > > {-# LANGUAGE LambdaCase #-} > > ... > > someprocedure :: IO Bool > someprocedure = do > connectGearman somebs somehost someport >>= \case > Left e -> return False > Right client -> do > flip evalStateT client $ do > submitJob somefunc somebs >>= \case > Left e -> return False > Right bs -> do > -- do something with bs > return True > > On Wed, Mar 15, 2017 at 4:18 PM, wrote: > > Hi, > > I repeat my unanswered question in hope to find here some help: > > > > Unfortunately the package hgearman does not provide any test or example and > > I can't work it out for myself how should be combined connectGearman and > > submitJob to put a job to the gearman job server. > > > > The result of connectGearman is: > > > > ghci> conn <- connectGearman (B.pack "x") ("localhost"::HostName) > > (4730::Port) > > ghci> :t conn > > conn :: Either GearmanError GearmanClient > > > > but submitJob uses private function submit which deals with StateT. So I can > > only guess the result of connectGearman should be wrapped into S.StateT > > GearmanClient IO without faintest idea how to do that. > > > > > > _______________________________________________ > > Beginners mailing list > > Beginners at haskell.org > > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > From mike_k_houghton at yahoo.co.uk Sat Mar 18 21:11:20 2017 From: mike_k_houghton at yahoo.co.uk (mike h) Date: Sat, 18 Mar 2017 21:11:20 +0000 Subject: [Haskell-beginners] parse block comments Message-ID: Hi, Below is code I’m building up for simple monadic and applicative parsers from first principles. I’ve just added code for single line Haskell style comments. -- comment being '--' comment :: Parser () comment = do string "--" many (sat ( /='\n') ) return () — or as applicative comment' = string "--" *> many (sat (/='\n') ) I’d really appreciate help on writing a function for multi line comments! “{-“ and end with “-}” I know I need some sort of look ahead but can’t quite get the feel of how! Thanks Mike ====================================== import Control.Applicative import Data.Char newtype Parser a = P (String -> [(a,String)]) parse :: Parser a -> String -> [(a,String)] parse (P p) = p item :: Parser Char item = P (\s -> case s of [] -> [] (x:xs) -> [(x, xs)]) instance Functor Parser where -- fmap :: (a -> b) -> f a -> f b fmap g p = P (\inp -> case parse p inp of [] -> [] [(x, xs)] -> [(g x, xs)]) instance Applicative Parser where -- pure :: a -> Parser a -- (<*>) :: Parser (a -> b) -> Parser a -> Parser b pure x = P (\inp -> [(x, inp)]) pab <*> pa = P (\inp -> case parse pab inp of [] -> [] [(aTob, out)] -> parse (fmap aTob pa) out) three :: Parser (Char, Char) three = pure g <*> item <*> item <*> item where g x y z = (x, z) instance Monad Parser where -- return :: a -> Parser a return x = P (\inp -> [(x, inp)]) -- (>>=) :: Parser a -> (a -> Parser b) -> Parser b pa >>= f = P (\inp -> case parse pa inp of [] -> [] [(a, out)] -> parse (f a) out) instance Alternative Parser where -- empty :: Parser a empty = P (\inp -> []) -- (<|>) :: Parser a-> Parser a -> Parser a -- if p1 works the that one otherwise p2 p1 <|> p2 = P (\inp -> case parse p1 inp of [] -> parse p2 inp out -> out) sat :: (Char -> Bool) -> Parser Char sat p = do x <- item if p x then return x else empty digit :: Parser Char digit = sat isDigit lower :: Parser Char lower = sat isLower upper :: Parser Char upper = sat isUpper letter :: Parser Char letter = sat isAlpha alphanum :: Parser Char alphanum = sat isAlphaNum char :: Char -> Parser Char char x = sat (==x) string :: String -> Parser String string [] = return [] string s@(x:xs) = do char x *> string xs *> return s ident :: Parser String ident = do x <- lower xs <- many alphanum return (x:xs) ident' :: Parser String ident' = pure (:) <*> lower <*> many alphanum nat :: Parser Int nat = do xs <- some digit return (read xs) nat' :: Parser Int nat' = pure read <*> some digit space :: Parser () space = do many (sat isSpace ) return () space' :: Parser () space' = many (sat isSpace ) *> return () int :: Parser Int int = do char '-' n <- nat return (-n) <|> nat int' :: Parser Int int' = char '-' *> pure ((-1)*) <*> nat <|> nat token :: Parser a -> Parser a token p = do space v <- p space return v token' :: Parser a -> Parser a token' p = space *> p <* space identifier :: Parser String identifier = token ident natural :: Parser Int natural = token nat integer :: Parser Int integer = token int symbol :: String -> Parser String symbol xs = token (string xs) nats :: Parser [Int] nats = do symbol "[" n <- natural ns <- many ( do symbol "," natural ) symbol "]" return (n:ns) -- comment being '--' comment :: Parser () comment = do string "--" many (sat ( /='\n') ) return () comment' = string "--" *> many (sat (/='\n') ) nats' :: Parser [Int] -- sequence and ignore "[" and the rest -- the rest is fmap list cons into result of natural and the apply that to many others and -- finally ignore the closing "]" nats' = symbol "[" >> (:) <$> natural <*> many (symbol "," >> natural) <* symbol "]" From fa-ml at ariis.it Sat Mar 18 21:47:15 2017 From: fa-ml at ariis.it (Francesco Ariis) Date: Sat, 18 Mar 2017 22:47:15 +0100 Subject: [Haskell-beginners] parse block comments In-Reply-To: References: Message-ID: <20170318214715.GA14788@casa.casa> On Sat, Mar 18, 2017 at 09:11:20PM +0000, mike h wrote: > Hi, > > Below is code I’m building up for simple monadic and applicative parsers > from first principles. Hello Mike, You might want to check `manyTill` from Parsec to get an idea: manyTill :: (Stream s m t) => ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a] manyTill p end = scan where scan = do { end; return [] } <|> do { x <- p; xs <- scan; return (x:xs) } The 'trick' lies in <|> (alternative). Does that help? From mike_k_houghton at yahoo.co.uk Sat Mar 18 22:22:25 2017 From: mike_k_houghton at yahoo.co.uk (mike h) Date: Sat, 18 Mar 2017 22:22:25 +0000 Subject: [Haskell-beginners] parse block comments In-Reply-To: <20170318214715.GA14788@casa.casa> References: <20170318214715.GA14788@casa.casa> Message-ID: <7F565336-CB41-40AB-8AC8-250FC5EFC8BF@yahoo.co.uk> Hi Francesco, :) Yes! That really did help. Will post later when I’ve tidied what I’ve done but it seems correct. Thank you. M > On 18 Mar 2017, at 21:47, Francesco Ariis wrote: > > On Sat, Mar 18, 2017 at 09:11:20PM +0000, mike h wrote: >> Hi, >> >> Below is code I’m building up for simple monadic and applicative parsers >> from first principles. > > Hello Mike, > You might want to check `manyTill` from Parsec to get an idea: > > manyTill :: (Stream s m t) => ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a] > manyTill p end = scan > where > scan = do { end; return [] } <|> > do { x <- p; xs <- scan; return (x:xs) } > > > The 'trick' lies in <|> (alternative). Does that help? > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners -------------- next part -------------- An HTML attachment was scrubbed... URL: From mike_k_houghton at yahoo.co.uk Sat Mar 18 22:49:11 2017 From: mike_k_houghton at yahoo.co.uk (mike h) Date: Sat, 18 Mar 2017 22:49:11 +0000 Subject: [Haskell-beginners] parse block comments In-Reply-To: <20170318214715.GA14788@casa.casa> References: <20170318214715.GA14788@casa.casa> Message-ID: Monadic and applicative. blockCmnt :: Parser () blockCmnt = do string "{-" manyTill item (string "-}") return () manyTill p endp = scan where scan = do endp return [] <|> do x <- p xs <- scan return (x:xs) blockCmnt' :: Parser () blockCmnt' = string "{-" >> manyTill item (string "-}") >> return () manyTill' p endp = scan' where scan' = endp *> return [] <|> pure (:) <*> p <*> scan’ Thanks. M > On 18 Mar 2017, at 21:47, Francesco Ariis wrote: > > On Sat, Mar 18, 2017 at 09:11:20PM +0000, mike h wrote: >> Hi, >> >> Below is code I’m building up for simple monadic and applicative parsers >> from first principles. > > Hello Mike, > You might want to check `manyTill` from Parsec to get an idea: > > manyTill :: (Stream s m t) => ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a] > manyTill p end = scan > where > scan = do { end; return [] } <|> > do { x <- p; xs <- scan; return (x:xs) } > > > The 'trick' lies in <|> (alternative). Does that help? > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners From davemartinnyc at aol.com Sun Mar 19 00:42:38 2017 From: davemartinnyc at aol.com (Dave Martin) Date: Sat, 18 Mar 2017 20:42:38 -0400 Subject: [Haskell-beginners] State, StateT, or ST for game settings? Message-ID: <15ae4041ade-58a-82cf@webprd-a58.mail.aol.com> I would like to create a game with a "main menu" offering the user a choice of "playing the game" or accessing a "settings menu," in which he can change defaults that would affect the game play (e.g. board size, etc.). I know (barely) enough about the "IO monad" to write the menus and the basic gameplay, but what device do I need in order to manage the settings? A State monad? A StateT monad transformer? An ST monad? None of the above? I have some basic familiarity with the first two, but not enough to really grasp how they are actually used. -------------- next part -------------- An HTML attachment was scrubbed... URL: From fa-ml at ariis.it Sun Mar 19 00:59:05 2017 From: fa-ml at ariis.it (Francesco Ariis) Date: Sun, 19 Mar 2017 01:59:05 +0100 Subject: [Haskell-beginners] State, StateT, or ST for game settings? In-Reply-To: <15ae4041ade-58a-82cf@webprd-a58.mail.aol.com> References: <15ae4041ade-58a-82cf@webprd-a58.mail.aol.com> Message-ID: <20170319005905.GA3462@casa.casa> On Sat, Mar 18, 2017 at 08:42:38PM -0400, Dave Martin wrote: > I would like to create a game with a "main menu" offering the user a choice of "playing the game" or accessing a "settings menu," in which he can change defaults that would affect the game play (e.g. board size, etc.). > > I know (barely) enough about the "IO monad" to write the menus and the basic gameplay, but what device do I need in order to manage the settings? A State monad? A StateT monad transformer? An ST monad? None of the above? I have some basic familiarity with the first two, but not enough to really grasp how they are actually used. Hello Dave, State will do! Of course if you need to mix the two monads (State + IO) you need a State transformer (StateT) -F From brutallesale at gmail.com Wed Mar 22 11:44:23 2017 From: brutallesale at gmail.com (sasa bogicevic) Date: Wed, 22 Mar 2017 12:44:23 +0100 Subject: [Haskell-beginners] LYAH example Message-ID: <34CD86B8-A4DB-4776-8D88-05FF9F1C34E1@gmail.com> Hi All, Can someone clarify the example I got from LYAH book. This let statement is kinda confusing to me : applyLog :: (a, String) -> (a -> (b, String)) -> (b, String) applyLog (x, log) f = let (y, newLog) = f x in (y, log ++ newLog) I know that f applied to x should produce y and we append log with newLog but when reading ... f x in (y, ... I just don't see how f x becomes y in the let statement. Seems more readable if we could write ... = (f x, log ++ newLog) Thanks, Sasa { name: Bogicevic Sasa phone: +381606006200 } From fa-ml at ariis.it Wed Mar 22 12:30:33 2017 From: fa-ml at ariis.it (Francesco Ariis) Date: Wed, 22 Mar 2017 13:30:33 +0100 Subject: [Haskell-beginners] LYAH example In-Reply-To: <34CD86B8-A4DB-4776-8D88-05FF9F1C34E1@gmail.com> References: <34CD86B8-A4DB-4776-8D88-05FF9F1C34E1@gmail.com> Message-ID: <20170322123033.GA3991@casa.casa> On Wed, Mar 22, 2017 at 12:44:23PM +0100, sasa bogicevic wrote: > Hi All, > Can someone clarify the example I got from LYAH book. This let statement > is kinda confusing to me : > > applyLog :: (a, String) -> (a -> (b, String)) -> (b, String) > applyLog (x, log) f = let (y, newLog) = f x in (y, log ++ newLog) Hello Sasa, let's rewrite `applyLog`: applyLog :: (a, String) -> (a -> (b, String)) -> (b, String) applyLog (x, log) f = -- f :: a -> (b, String) let (y, newLog) = f x -- y :: b -- newLog :: String in (y, log ++ newLog) -- (b, String) f applied to x doesn't produce just `y`, but `y` and `newLog` (in a Tuple). It is perfectly ok to specify a pattern: let (y, newLog) = f x -- legal let xyz = f x -- legal too. The first form saves you a `fst`/`snd` Is it clearer now? From brutallesale at gmail.com Wed Mar 22 13:29:05 2017 From: brutallesale at gmail.com (sasa bogicevic) Date: Wed, 22 Mar 2017 14:29:05 +0100 Subject: [Haskell-beginners] LYAH example In-Reply-To: <20170322123033.GA3991@casa.casa> References: <34CD86B8-A4DB-4776-8D88-05FF9F1C34E1@gmail.com> <20170322123033.GA3991@casa.casa> Message-ID: Ahhhh I see, thank you very much for the response! Have a nice day, Sasa { name: Bogicevic Sasa phone: +381606006200 } > On Mar 22, 2017, at 13:30, Francesco Ariis wrote: > > On Wed, Mar 22, 2017 at 12:44:23PM +0100, sasa bogicevic wrote: >> Hi All, >> Can someone clarify the example I got from LYAH book. This let statement >> is kinda confusing to me : >> >> applyLog :: (a, String) -> (a -> (b, String)) -> (b, String) >> applyLog (x, log) f = let (y, newLog) = f x in (y, log ++ newLog) > > Hello Sasa, > let's rewrite `applyLog`: > > applyLog :: (a, String) -> (a -> (b, String)) -> (b, String) > applyLog (x, log) f = > -- f :: a -> (b, String) > let (y, newLog) = f x -- y :: b > -- newLog :: String > in (y, log ++ newLog) -- (b, String) > > f applied to x doesn't produce just `y`, but `y` and `newLog` (in > a Tuple). It is perfectly ok to specify a pattern: > > let (y, newLog) = f x -- legal > > let xyz = f x -- legal too. The first form saves you a `fst`/`snd` > > Is it clearer now? > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners From w.s.swierstra at uu.nl Mon Mar 27 08:19:15 2017 From: w.s.swierstra at uu.nl (Wouter Swierstra) Date: Mon, 27 Mar 2017 10:19:15 +0200 Subject: [Haskell-beginners] Call for participation: Utrecht Summer School Message-ID: <8c4df6bd-d639-63ae-5053-9c86ba5d5035@uu.nl> Call for Participation SUMMER SCHOOL ON APPLIED FUNCTIONAL PROGRAMMING Utrecht, the Netherlands, 21-25 August 2017 http://www.afp.school ## ABOUT The Applied Functional Programming summer school has been running for almost ten years. We aim to educate aspiring Haskell programmers beyond the basic material covered by many textbooks. The lectures will cover several more advanced topics regarding the theory and practice of Haskell programming, including topics such as: * lambda calculus; * monads and monad transformers; * lazy evaluation; * generalized algebraic data types; * type families and type-level programming; * concurrency and parallelism. The summer school consists of a mix of lectures, labs, and a busy social program. ## LECTURERS Utrecht staff: * Johan Jeuring * Doaitse Swierstra * Wouter Swierstra Guest lectures: * Simon Marlow (Concurrency and parallelism) * Luite Stegeman (GHCJS) ## PREREQUISITES We expect students to have a basic familiarity with Haskell already. You should be able to write recursive functions over algebraic data types, such as lists and trees. There is a great deal of material readily available that covers this material. If you’ve already started learning Haskell and are looking to take your functional programming skills to the next level, this is the course for you. ## DATES Registration deadline: 1 August, 2017 School: 21-25 August ## COSTS €1700 - Housing and registration €1500 - Registration only We offer a €1000 discount for students and staff members affiliated with a university. ## FURTHER INFORMATION Further information, including instructions on how to register, is available on our website: http://www.afp.school From mike_k_houghton at yahoo.co.uk Mon Mar 27 11:04:08 2017 From: mike_k_houghton at yahoo.co.uk (mike h) Date: Mon, 27 Mar 2017 11:04:08 +0000 (UTC) Subject: [Haskell-beginners] Parallel processing... References: <1878780365.6137892.1490612648280.ref@mail.yahoo.com> Message-ID: <1878780365.6137892.1490612648280@mail.yahoo.com> Hi, I have a list of lists - a grid [[ ]]  of complex numbers and I map a function over each number in the grid. Each computation on a value at (r, c) is independent of any and all other calculations. This strikes me as being something that can be done in parallel by  creating , say 4 quadrants and mapping over each and combining when done, or doing each row in parallel etc. etc. So I'm really just asking for advice or pointers on the Haskell libraries etc that I should start with but I'm not really looking to import an  uber-package that will do most of it for me. I want to learn a little  more Haskell by working from a few concurrency primitives. Thanks Mike -------------- next part -------------- An HTML attachment was scrubbed... URL: From toad3k at gmail.com Mon Mar 27 12:21:19 2017 From: toad3k at gmail.com (David McBride) Date: Mon, 27 Mar 2017 08:21:19 -0400 Subject: [Haskell-beginners] Parallel processing... In-Reply-To: <1878780365.6137892.1490612648280@mail.yahoo.com> References: <1878780365.6137892.1490612648280.ref@mail.yahoo.com> <1878780365.6137892.1490612648280@mail.yahoo.com> Message-ID: It's hard to say what level you'll want your libraries to be. Theoretically all the functionality you need is in base. Control.Parallel and Control.Concurrent have functions for that, although you'll have to learn how to use them from various tutorials around. If the function you are mapping is pure, you might try the parallel package. If it is monadic you might try the monad-par package. There are parMap and parFor functions in monad-par-extras package which do exactly what you are looking for. If you search for parallel on hackage you'll find a plethora of well maintained packages in this domain as it is one of those things haskell is best at. On Mon, Mar 27, 2017 at 7:04 AM, mike h wrote: > Hi, > > I have a list of lists - a grid [[ ]] of complex numbers and I map a > function over each number in the grid. Each computation on a value at (r, c) > is independent of any and all other calculations. This strikes me as being > something that can be done in parallel by creating , say 4 quadrants and > mapping over each and combining when done, or doing each row in parallel > etc. etc. > > So I'm really just asking for advice or pointers on the Haskell libraries > etc that I should start with but I'm not really looking to import an > uber-package that will do most of it for me. I want to learn a little more > Haskell by working from a few concurrency primitives. > > Thanks > > Mike > > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > From mike_k_houghton at yahoo.co.uk Mon Mar 27 17:05:52 2017 From: mike_k_houghton at yahoo.co.uk (mike h) Date: Mon, 27 Mar 2017 18:05:52 +0100 Subject: [Haskell-beginners] Parallel processing... In-Reply-To: References: <1878780365.6137892.1490612648280.ref@mail.yahoo.com> <1878780365.6137892.1490612648280@mail.yahoo.com> Message-ID: Thanks David, I’ll look in to the links. Mike > On 27 Mar 2017, at 13:21, David McBride wrote: > > It's hard to say what level you'll want your libraries to be. > Theoretically all the functionality you need is in base. > Control.Parallel and Control.Concurrent have functions for that, > although you'll have to learn how to use them from various tutorials > around. > > If the function you are mapping is pure, you might try the parallel > package. If it is monadic you might try the monad-par package. There > are parMap and parFor functions in monad-par-extras package which do > exactly what you are looking for. > > If you search for parallel on hackage you'll find a plethora of well > maintained packages in this domain as it is one of those things > haskell is best at. > > On Mon, Mar 27, 2017 at 7:04 AM, mike h wrote: >> Hi, >> >> I have a list of lists - a grid [[ ]] of complex numbers and I map a >> function over each number in the grid. Each computation on a value at (r, c) >> is independent of any and all other calculations. This strikes me as being >> something that can be done in parallel by creating , say 4 quadrants and >> mapping over each and combining when done, or doing each row in parallel >> etc. etc. >> >> So I'm really just asking for advice or pointers on the Haskell libraries >> etc that I should start with but I'm not really looking to import an >> uber-package that will do most of it for me. I want to learn a little more >> Haskell by working from a few concurrency primitives. >> >> Thanks >> >> Mike >> >> >> _______________________________________________ >> Beginners mailing list >> Beginners at haskell.org >> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners >> From erik.tillett at gmail.com Mon Mar 27 23:54:55 2017 From: erik.tillett at gmail.com (Erik Tillett) Date: Mon, 27 Mar 2017 19:54:55 -0400 Subject: [Haskell-beginners] Suggestions for way to improve / clean up this code? Message-ID: I'm looking for sugestions on how to better structure this code. I stuck it in a pastbin: https://pastebin.com/gQFmvq6W/ Would a State monad help? Thanks! -------------- next part -------------- An HTML attachment was scrubbed... URL: From fa-ml at ariis.it Tue Mar 28 00:46:26 2017 From: fa-ml at ariis.it (Francesco Ariis) Date: Tue, 28 Mar 2017 02:46:26 +0200 Subject: [Haskell-beginners] Suggestions for way to improve / clean up this code? In-Reply-To: References: Message-ID: <20170328004626.GA17392@casa.casa> On Mon, Mar 27, 2017 at 07:54:55PM -0400, Erik Tillett wrote: > I'm looking for sugestions on how to better structure this code. I stuck > it in a pastbin: > > https://pastebin.com/gQFmvq6W/ > > Would a State monad help? > > Thanks! Hello Erik, a couple of notes: - boolToInt is the same as `fromEnum` λ> :t fromEnum fromEnum :: Enum a => a -> Int - there are a lot of redundant brackets, like if (zReg c) then c{pc = address} else c ^ ^ minor errors like this are easily caught by hlint As for the state monad: you are correctly using monads to capture the idea of "things that can fail" (Either), judging by the function signatures I don't see the need for a State monad (i.e. I don't see signatures that end in (Something, SomeResult). (or maybe I am misreading the code, in that case please fire again) From erik.tillett at gmail.com Tue Mar 28 15:55:36 2017 From: erik.tillett at gmail.com (Erik Tillett) Date: Tue, 28 Mar 2017 11:55:36 -0400 Subject: [Haskell-beginners] Suggestions for way to improve / clean up this code? In-Reply-To: <20170328004626.GA17392@casa.casa> References: <20170328004626.GA17392@casa.casa> Message-ID: Ooh, thanks for that! I didn't even know hlint existed. That's pretty cool. As far as use of the State monad... What I was thinking is that I've got the CPU state that gets fed into just about every function, which then returns a new modified CPU. So I'm constantly passing the CPU around. I might want to be able to have hooks that allow me to escape normal updating of the CPU when something specific happens (maybe an error, maybe something else). Would State help with that or are there any better alternatives? Thanks! On Mon, Mar 27, 2017 at 8:46 PM, Francesco Ariis wrote: > On Mon, Mar 27, 2017 at 07:54:55PM -0400, Erik Tillett wrote: > > I'm looking for sugestions on how to better structure this code. I stuck > > it in a pastbin: > > > > https://pastebin.com/gQFmvq6W/ > > > > Would a State monad help? > > > > Thanks! > > Hello Erik, > a couple of notes: > > - boolToInt is the same as `fromEnum` > > λ> :t fromEnum > fromEnum :: Enum a => a -> Int > > - there are a lot of redundant brackets, like > > if (zReg c) then c{pc = address} else c > ^ ^ > > minor errors like this are easily caught by hlint > > As for the state monad: you are correctly using monads to capture > the idea of "things that can fail" (Either), judging by the function > signatures I don't see the need for a State monad (i.e. I don't > see signatures that end in (Something, SomeResult). > (or maybe I am misreading the code, in that case please fire again) > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > -- ========================= Erik Tillett 614-893-0420 7797 Gladshire Blvd. Lewis Center, OH 43035 ========================= -------------- next part -------------- An HTML attachment was scrubbed... URL: