[Haskell-beginners] ICFP 2007

Rafael Gustavo da Cunha Pereira Pinto RafaelGCPP.Linux at gmail.com
Wed Aug 27 19:46:44 EDT 2008


First of all, sorry asking too many questions!

I am using the ICFP 2007 (http://save-endo.cs.uu.nl/) problem as a case for
learning Haskell.

I started with the prototype, listed below


=================Main.hs=======================
module Main(main) where

import qualified Data.ByteString.Lazy.Char8 as L
import qualified Data.ByteString.Char8 as S

import Data.ByteString.Search.BoyerMoore as BM
import Debug.Trace

data DNA=DNA {prefix :: L.ByteString, suffix :: L.ByteString}


main::IO ()
main=do
    d<-L.readFile "endo.dna"
    let dna=DNA (L.pack "IIIIIIIIIIICCICCICCICFFIIIIIIIIIIIIIIIICFP")  d
    let pat=S.pack "ICFP"
    print $ take 1 $ matchSL pat $ L.append (prefix dna) (suffix dna)
=================EOF Main.hs===================


My question is:

Knowing that the searched pattern is in DNA prefix, will "suffix dna" ever
be called here?
I mean, will the "append" suspension ever be fully evaluated?


I am thinking on using a data type like

data DNA=DNA {prefix::L.ByteString, worked::L.ByteString,
suffix::ByteString}

The invariant is that worked should be L.empty whenever prefix is L.empty.


Thanks in advance

-- 
Rafael Gustavo da Cunha Pereira Pinto
Electronic Engineer, MSc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20080827/3be4a8e4/attachment.htm


More information about the Beginners mailing list