Re: Beginners Digest, Vol 104, Issue 16

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Beginners Digest, Vol 104, Issue 16

tscosj tscosj
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, <[hidden email]> wrote:
Send Beginners mailing list submissions to
        [hidden email]

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
        [hidden email]

You can reach the person managing the list at
        [hidden email]

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 <[hidden email]>
To: [hidden email]
Subject: Re: [Haskell-beginners] Type error when using splitOn
        function.
Message-ID: <20170222133116.GA14860@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" <[hidden email]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[hidden email]>
Subject: Re: [Haskell-beginners] Type error when using splitOn
        function.
Message-ID:
        <[hidden email]>
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 <[hidden email]>:

> 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
> [hidden email]
> 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: <http://mail.haskell.org/pipermail/beginners/attachments/20170222/0d194b9d/attachment-0001.html>

------------------------------

Message: 3
Date: Wed, 22 Feb 2017 15:27:39 +0000
From: PICCA Frederic-Emmanuel
        <[hidden email]>
To: "[hidden email]" <[hidden email]>
Subject: [Haskell-beginners] How to link two Types
Message-ID:
        <[hidden email]>

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 <extract type a from type t> DIM1)

thanks for your help

Frederic


------------------------------

Message: 4
Date: Wed, 22 Feb 2017 10:59:38 -0500
From: David McBride <[hidden email]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[hidden email]>
Subject: Re: [Haskell-beginners] How to link two Types
Message-ID:
        <[hidden email]>
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
<[hidden email]> 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 <extract type a from type t> DIM1)
>
> thanks for your help
>
> Frederic
> _______________________________________________
> Beginners mailing list
> [hidden email]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners


------------------------------

Message: 5
Date: Wed, 22 Feb 2017 16:19:41 +0000
From: PICCA Frederic-Emmanuel
        <[hidden email]>
To: "The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell" <[hidden email]>
Subject: Re: [Haskell-beginners] How to link two Types
Message-ID:
        <[hidden email]>

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 <[hidden email]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[hidden email]>
Subject: Re: [Haskell-beginners] How to link two Types
Message-ID:
        <CAN+Tr43H_Z9ckhW+f6GqeBXf_O=LX=[hidden email]>
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
<[hidden email]> 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
> [hidden email]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners


------------------------------

Subject: Digest Footer

_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners


------------------------------

End of Beginners Digest, Vol 104, Issue 16
******************************************


_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
Loading...