Send Beginners mailing list submissions to
[email protected]
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
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. Re: Tagged types (PICCA Frederic-Emmanuel)
----------------------------------------------------------------------
Message: 1
Date: Thu, 11 Oct 2018 11:34:20 +0000
From: PICCA Frederic-Emmanuel
<[email protected]>
To: "The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell" <[email protected]>
Subject: Re: [Haskell-beginners] Tagged types
Message-ID:
<a2a20ec3b8560d408356cac2fc148e53015b33c...@sun-dag3.synchrotron-soleil.fr>
Content-Type: text/plain; charset="Windows-1252"
Hello, So I end-up for now with two singletons for my SomeDataCollection
So I red the Datacollection from an xml file (col) then I create the
SomeDataCollection type depending on a bunch of values found in the
Datacollection.
like this.
return $ if "ref-" `isPrefixOf` imagePrefix col
then case imageSuffix col of
(Just "cbf") -> SomeDataCollection
SCaracterization SCbf (coerce col)
(Just "h5") -> SomeDataCollection
SCaracterization SHdf5 (coerce col)
(Just _) -> SomeDataCollection
SCaracterization SCbf (coerce col)
Nothing -> SomeDataCollection
SCaracterization SCbf (coerce col)
else case imageSuffix col of
(Just "cbf") -> SomeDataCollection
SCollect SCbf (coerce col)
(Just "h5") -> SomeDataCollection SCollect
SHdf5 (coerce col)
(Just _) -> SomeDataCollection SCollect
SCbf (coerce col)
Nothing -> SomeDataCollection SCollect
SCbf (coerce col)
Now I would like to do something like
let t = if "ref-" `isPrefixOf` imagePrefix col
then SCaracterization
else SCollect
and then
return SomeDatacollection t f (coerce col)
But If I try to do this I have an error like this
src/ISPyB/Soap.hs:119:37-44: error:
• Couldn't match type ‘'Collect’ with ‘'Caracterization’
Expected type: SCollectType 'Caracterization
Actual type: SCollectType 'Collect
• In the expression: SCollect
In the expression:
if "ref-" `isPrefixOf` imagePrefix col then
SCaracterization
else
SCollect
In an equation for ‘t’:
t = if "ref-" `isPrefixOf` imagePrefix col then
SCaracterization
else
SCollect
how can I fix this and make the code better to read.
thanks
Fred
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 124, Issue 7
*****************************************